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.
Subject: Re: renaming files References: <email@example.com> From: firstname.lastname@example.org (John DuBois) Date: 26 Nov 2001 07:37:15 GMT In article <email@example.com>, Duilio Foschi <firstname.lastname@example.org> 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 email@example.com. KC6QKZ/AE https://www.armory.com./~spcecdt/
Got something to add? Send me email.
I wanted to learn how to swim, so Google showed me how to turn on the water at the sink and let me splash it around a bit. They then dragged me into a helicopter, flew way out into the ocean and dumped me out. (Tony Lawrence)