I need a program that can rename large amounts of files based on the following criteria…
A program I use that dumps images dumps them in the following way…
RECID_COMPTYPE_IMAGETYPE_####.gif
Where RECID and COMPTYPE are varying different numbers depending on the image, IMAGETYPE is a small string that also varies from image to image. The #### are image index numbers, so they go from 0001 up to whatever the last image dumped is.
Basically, I want to just get rid of the image index #### for all the filenames, but I’m dealing with thousands and thousands of files, so going through and doing it manually would not be feasible.
If it helps, RECID is always 8 chars, COMPTYPE is always 2 chars, and IMAGETYPE is always 3 chars. I think since they are so uniform in length, it should be easy to remove the chars between position x-y, in the file name… but I just don’t know of any programs that do this.
On Linux, this will work in the bash shell and probably some others I think. cd to the directory then:
*for i in .gif; do mv “i" "{i:0:15}.gif”; done
Change mv to echo to test, it will echo the old filename and the new filename.
This takes a file one at a time and assigns it’s name to the $i variable, then moves it from the full filename to a new file named with the first 16 characters of the old name with .gif tacked on the end. It will go through all gif files in the directory.