The script referenced is a Ksh script. Note that you MUST quote wild cards to avoid shell expansion.
It is a complex script. "ren -h | wc -l" generates 251 lines alone!
Be aware of ambiguous cases and collisions - the script tries to be intelligent about those things, but they are ultimately your responsibility.
I tested this on Mac OS X and only had to change the "#!/bin/ksh93" to "#!/bin/ksh".
Without this, the simple case is trivial from the command line:
for i in 01*; do j=`echo $i | sed 's/^01/02/'`; mv $i $j; done
The more complex tasks are not that much harder, though I'd go to Perl for those.
renaming files ren
Subject: Re: renaming files References: <firstname.lastname@example.org> From: email@example.com (John DuBois) Date: 26 Nov 2001 07:37:15 GMT In article <firstname.lastname@example.org>, Duilio Foschi <email@example.com> wrote: >I want to rename all files starting with 01 into files starting with >02. > >The command > >ren 01*.* 02*.* > >works under Dos. > >I was expecting the command > >mv 01* 02* > >to work under Unix, but it doesn't. I would do:
ren '01*' '02*' Or, if what I actually wanted was to increment the first two digits of every filename: ren '[0-9][0-9]*' '[0-9][0-9]*.tmp' ren -m1:2=i+1 -z2 '[0-9][0-9]*.tmp' '[0-9][0-9]*' ftp://ftp.armory.com./pub/scripts/ren John -- John DuBois firstname.lastname@example.org. KC6QKZ/AE http://www.armory.com./~spcecdt/
Got something to add? Send me email.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version
Increase ad revenue 50-250% with Ezoic