Renaming Multiple Files

Ever had a project where you needed to rename multiple files with similar naming conventions? I had a personal project where I was converting multiple images into large PDF files. The list looked similar to this with the numbers 1 through 9 as single digits:


If I selected all the files in Windows Vista and right clicked the option to “Combine Supported files in Acrobat…” is available. When it opens the list in the “Combine” window the files are listed in the order of 1, 10, 11, 2, 20, 21, 3, etc. That isn’t the order I wanted them in and renaming each file would take forever.

CMD to the rescue!

I know that some things are easier from a dos prompt.* After a bit of research I came accross a way to find similar files and rename them. First let’s define what I want to do: I want to find all files that end in -1.jpg and replace them with -01.jpg. Then repeat for -2, -3, -4 etc.

Open CMD

If you hold Ctrl + Shift and Right Click in a folder the option to “Open Command Window Here” is available. Click on this to open a cmd screen already in the folder where you want to work.

Rename, Find & Replace

Renaming Files in the cmd WindowI used the “ren” function to rename. I’m not sure exactly the semantics of this function, but if I put ren, space, the search criteria, space, the replacement criteria, it works. So in the case of our list above I used:

ren *-1.jpg *-01.jpg

It then found all the files that ended in -1.jpg and renamed them to end with -01.jpg. The * is a wildcard representing the first part of the file name. After you do type in the first line and hit enter the files will be renamed. Then you will have a brand new line to type things into. Before you do that hit the right arrow on your keyboard a few times. You will notice that the previous formula is being revealed as you do. When you get to the spot you want to change type in the new information. So in my case when I got to “ren *-“, I typed in a 2 and when I got to the “ren *-2.jpg *-0”, I typed in 2 again. I continued this (see image right) till I had all single digits replaced and the files would now sort properly.

Repeat Rename

If anyone knows how to make this repeat for subsequent numbers automatically please leave the info in the comments below. Thanks.