Geek Challenge: Mass rename
By dlacher on May 12, 2005
I run into this problem when I am pulling images off my digital camera. The camera assigns names like DSCFXXXX.JPG . This is all well and good until I want to store images that have the same name for a variety of reasons like they were on different flash cards and the camera number from 0001 for each card. So after unloading all of the images off the cards in seperate dirs I would like to combine them into the same dir. So dir1 has files DSCF0001.JPG through DSCF0150.JPG, and dir2 then has files DSCF0001.JPG through DSCF0120.JPG.
So what do I feel is a valid solution is, to create a script that will rename files in a given dir starting with a new number. For the example above I would go into dir2 and rename the files to start at DSCF0151.JPG and up. One catch is that what if I had the directories flipped and I wanted to rename the files in dir1 to start at DSCF0121.JPG and up... ah then one has to be careful since 0121 all ready exists in that directory...
Anyways have fun w/ the challenge. Please feel free to leave your solutions in the comments of this entry.
Remember that comments are free form but accept HTML so you might want to use the <pre> tags around the code.