Greg Freemyer wrote:
On Mon, Mar 3, 2008 at 6:53 PM, Greg Freemyer
wrote: All,
I have a directory with several hundred files in it. All in alphabetical order the way I need them.
I need to rename them to be in a totally different sequence.
ie. Currently nnn_mmm_lll.tif
Need to rename AAA_xxxx.tif where AAA is fixed, and xxxx is sequence I can specify the starting point for.
I'm about to write a shell script to do this, but would be nice to have a pre-existing tool I could call on. mmv is close I think, but I don't know how to do the sequence number with it.
Thanks Greg
Still hoping for a better solution, but here is the bash script I came up with as a starting point. It works for this one time. I'll tweak it more if I have to reuse it.
#!/bin/bash
SOURCE=orig DEST=renamed
START=2076 PREFIX=KGI-00 SUFFIX=.tif
mkdir $DEST
ls $SOURCE > source-list
while read source ; do echo cp $source $DEST/$PREFIX$START$SUFFIX cp "$source.tif" $DEST/$PREFIX$START$SUFFIX START=`expr $START + 1`; done < source-list
personally, i would pipe ls into xargs, and one each file, form the destination name by running each file's name through a sed script. A little harder to do at first, but more reliable in the long run
Greg
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org