From owner-freebsd-questions Mon Jan 14 14:41:33 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 37A5037B41C for ; Mon, 14 Jan 2002 14:41:25 -0800 (PST) Received: from hades.hell.gr (patr530-a233.otenet.gr [212.205.215.233]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id g0EMfKY07996; Tue, 15 Jan 2002 00:41:21 +0200 (EET) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id g0ELZ8e31947; Mon, 14 Jan 2002 23:35:08 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Mon, 14 Jan 2002 23:35:08 +0200 From: Giorgos Keramidas To: "J.S." Cc: freebsd-questions@freebsd.org Subject: Re: Filename tool? Message-ID: <20020114213507.GG31045@hades.hell.gr> References: <20020114205116.3183e89a.johann@broadpark.no> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5CUMAwwhRxlRszMD" Content-Disposition: inline In-Reply-To: <20020114205116.3183e89a.johann@broadpark.no> User-Agent: Mutt/1.3.25i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --5CUMAwwhRxlRszMD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2002-01-14 20:51:15, J.S. wrote: > Hi. > > I have large collection of files within many branches of filetypes, and > before they enter my 'main' collection I have to manually change the > filenames so that I am satisfied with the way they are. > > E.g.: > > Artist_-_Dis'z_Deh_Name_Of_My_Song_(My_Remix)-GROUP.mp3 > > I rename to: > > artist-disz_deh_name_of_my_song-my_remix-group.mp3 > > Is that 100% POSIX compliant or what? =3D) > > Anyway, I was wondering if there existed a tool which can organize both > files and directories the same way I do. Perhaps even better? I recently got a cdrom in my snail mail with several dozens of mp3 collections. The files were all in that style so popular among the Windows world, with spaces between words, parentheses, and a ton of other characters that would make my life more difficult. Your friend is your FreeBSD base-system. It has all the tools you need to make scripts like: #!/bin/sh for fname in `find . -depth` ;do # strip all non alpha/digit/space/./-/_ characters fa=3D"`echo \"${fname}\" | sed -e 's/[^ [:alpha:][:digit:].-_]//g'`" # replace spaces with _ fb=3D"`echo \"${fa}\" | sed -e 's/[[:space:]][[:space:]]/_/g'`" # lowercase all fc=3D"`echo \"${fb}\" | tr A-Z a-z`" # ... # ... do what other stuff you want with the filename # ... mv "${fname}" "${fc}" done Of course, while you're testing a script like the one above, you might want to use "echo mv" instead of "mv". This way you can verify that the mv(1) command will rename the file to a name that you like, and then run the same script without "echo" to actually do the rename. --=20 Giorgos Keramidas . . . . . . . . . keramida@{ceid.upatras.gr,freebsd.org} FreeBSD Documentation Project . . . http://www.freebsd.org/docproj/ FreeBSD: The power to serve . . . . http://www.freebsd.org/ --5CUMAwwhRxlRszMD Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) iD8DBQE8Q08L1g+UGjGGA7YRAvgDAJ9zmOqNAdGn6KUoQYwjWgHJa1zW/ACghe5I qqz+HbnYlORd+uhZ76nowFs= =SwNu -----END PGP SIGNATURE----- --5CUMAwwhRxlRszMD-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message