[opensuse] Need a tool like mmv, but to generate sequential names
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 -- Greg Freemyer Litigation Triage Solutions Specialist http://www.linkedin.com/in/gregfreemyer First 99 Days Litigation White Paper - http://www.norcrossgroup.com/forms/whitepapers/99%20Days%20whitepaper.pdf The Norcross Group The Intersection of Evidence & Technology http://www.norcrossgroup.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Mon, Mar 3, 2008 at 6:53 PM, Greg Freemyer
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 Greg -- Greg Freemyer Litigation Triage Solutions Specialist http://www.linkedin.com/in/gregfreemyer First 99 Days Litigation White Paper - http://www.norcrossgroup.com/forms/whitepapers/99%20Days%20whitepaper.pdf The Norcross Group The Intersection of Evidence & Technology http://www.norcrossgroup.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
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
Aaron Kulkis wrote:
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.
Agreed. Glad to see you back under the correct moniker. -- David C. Rankin, J.D., P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
David C. Rankin wrote:
Aaron Kulkis wrote:
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.
Agreed.
Glad to see you back under the correct moniker.
Well, that didn't last long. But I have more time -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Monday 03 March 2008 16:53, Greg Freemyer wrote:
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.
Greg, I think krename can do most of this (if you don't mind a GUI). You can specify a prefix "AAA_", set a custom file name of "" and include a sequence of four (or more) digits starting where you like for the renamed file. I'm just not clear how the "xxxx" for each file is determined, if it is simply based on the numerical order of nnn_mmm_lll or something more sophisticted. krename can sort on numerical order for the input files, so that may serve your purpose. HTH. -- Don -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (5)
-
Aaron Kulkis
-
David C. Rankin
-
Don Raboud
-
Greg Freemyer
-
Screw You Goonish Thug