Mailinglist Archive: opensuse (2459 mails)

< Previous Next >
Re: [opensuse] Re: Need a tool like mmv, but to generate sequential names
  • From: Aaron Kulkis <akulkis01@xxxxxxxxx>
  • Date: Tue, 04 Mar 2008 02:41:45 -0500
  • Message-id: <47CCFD39.5060106@xxxxxxxxx>
Greg Freemyer wrote:
On Mon, Mar 3, 2008 at 6:53 PM, Greg Freemyer <greg.freemyer@xxxxxxxxx> 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@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups