Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Aug 1998 21:05:05 -0500
From:      Dan Nelson <dnelson@emsphone.com>
To:        Patrick Seal <patseal@hyperhost.net>, FBSDQ <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Renaming multiple files
Message-ID:  <19980829210505.A12635@emsphone.com>
In-Reply-To: <000001bdd3b3$db1d9e40$0100a8c0@local.hyperhost.net>; from "Patrick Seal" on Sat Aug 29 21:16:46 GMT 1998
References:  <000001bdd3b3$db1d9e40$0100a8c0@local.hyperhost.net>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
In the last episode (Aug 29), Patrick Seal said:
> Let's say I have two files in two different directories.
> /foo/bar.aaa
> /bar/foo.aaa
> 
> I want to rename the extensions to:
> /foo/bar.bbb
> /bar/foo.bbb
> 
> Can someone give point me to some sort of shell or perl script, or possibly
> just a command that can let me do this simultaneously?

For one-time replacements, I recommend ports/misc/mmv.  Lets you do
things like: mmv "*.aaa" "=1.bbb"

Or, if you're script-minded or want portability to systems without mmv:

for i in */*.aaa ; do
   mv $i ${i%.aaa}.bbb
done

should work.  If you want to recurse abitrary directory levles, replace
*/*.aaa with `find . -name "*.aaa"` .

	-Dan Nelson
	dnelson@emsphone.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?19980829210505.A12635>