Batch File Renamer

Hey all, I have a question for you.

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.

Any ideas? Maybe write a script?

What platform?

If you’re on Windows, I’ve used this one for batch file renaming.

If you’re wanting to automate, I think you could write a cmd file using their command line setup.

Or a script would do it, if that floats your boat.

I could do it on either Linux or Windows. I’m going to look at the program you linked redtail, see if it can do what I need. Thanks!

That program worked wonders! Thanks :slight_smile:

Sounds like you found something you like.

However, another option is Bulk Rename Utility

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.

touch 12345678_12_123_0001.gif

touch 12345679_12_123_0002.gif

touch 12345670_12_123_0003.gif

ls -1

12345670_12_123_0003.gif
12345678_12_123_0001.gif
12345679_12_123_0002.gif

for i in *.gif; do mv “i" "{i:0:15}.gif”; done

ls -1

12345670_12_123.gif
12345678_12_123.gif
12345679_12_123.gif

J-P-L, that one works even better! Thanks so much :slight_smile:

Fubaya, Thanks! I’ll give that method a try too :slight_smile:

That is a nice utility, J-P L!