Batch renaming of photo files

There are many occasions when I want to rename a whole group of photos. At times to give them names that indicate the subject or location, sometimes just to simplify the names. Windows Live Photo Gallery attaches size information when resizing, it appends “revision” numbers when using “Make a copy” or attaches “Copy” when using copy and paste. Here is a group of photos after a number of operations (as seen in Windows Explorer) – this is , of course, a bit of an exaggeration:


So I want to rename them and just keep the number assigned by the camera, and replace the “cameras “initials” with my own. Can Photo Gallery rename a whole bunch at the same time? Yes, it can, but you may not like the way it does it. When you select your thumbnails and hover the pointer over the file name field in the info pane, you get something like this:



It shows all the file names of the selected thumbnails. Maybe we can just type the new name into the box? Type in “ABC” image And here is the result (again as seen in Windows Explorer):


Not exactly what I had in mind. The camera-assigned numbers are gone, and the only distinction is the sequential numbers in parentheses. Can we do better? Yes, but not in Photo Gallery.

Batch Rename – the old-fashioned way

Here is my chance to take you on a nostalgia trip. Windows 7 (and Vista, as well as earlier versions) has a feature called “command prompt”. That gives you a small window which looks just like computer screens in the days of yore, “DOS”. In “command mode” you can do most anything! – You can tell my age by this remark, can’t you? Ah, those were the days, when a “mouse” was a varmint pest, a “pointer” was a hunting dog, and “graphic” was your language when you saw the results of a misspelled command. But enough reminiscing. You can use this mode to rename a whole folder full of files. There are limitation, though.

Click the Start button and type “cmd”. The program name “cmd.exe” will show at the top of the menu, just press Enter and the time machine is on its way.

image image

Note to XP users: It works just fine in XP, but there are a few differences. See the note on this at the bottom of this post.

When the “command prompt” windows opens you see Windows version and a copyright notice, shown here is what you get in Windows 7.

Then you see folder location followed by a “>” and a flashing underline – That is the command prompt where you type the commands – the mouse does not work in this window!

The folder location will be your personal folder as indicated by your name. Since I want to change the names of photo files in a Pictures folder, the first step is to go into that folder. Now in the early days, folders were called “directories”, so I want to “change the directory” to the folder containing the photos. That folder is in “Pictures”, and is inside folder “2010-4-13 002” and is called “demo 2”. The command for changing directory is “cd” – “change directory” – followed by the name of the directory. A command is submitted by pressing the Enter key. In the command back-slashes are used to separate the folder names. Here is the command and the response:


Next comes the command to change the file name of all my photo files that start with “DSC_”. I want to replace the first four characters and retain the next four characters, the number assigned by the camera. And I want to drop everything after that and before the “dot”, and want to retain the suffix. So the command goes like this: “ren” is “rename” (you can spell it out) this is followed by the name of the file to change and that is followed by the new name to be assigned. At the command prompt, it is possible to use “wild-card characters” to allow the command to process multiple files. There are two such wild-card characters that we can use: “?” – that means any character in that one position, and “*” meaning any number of characters. First here is the command, I will explain it momentarily:


The typed command is “ren DSC_????*.* LJK_????.*“  – “ren” means rename, the “DSC_” is the first part of all the names, “????” is “any characters in these four positions”. Then comes the famous “star” character (asterisk), which means “anything here to the “dot”. This is followed by the “.” – dot – character, and another star which means “anything after the “dot”.

The new name is then specified. Here I want my initials and an underline. This must be the same number of characters as are being replaced in the present name for the next part to work! This is followed by the “question mark string” identifying the character position to be retained. There should be nothing after that before the dot. Then the dot followed by whatever the suffix is in the current name – as shown by the “star”. Note that “missing start” in front of the dot in the new name: That is what drops all the extra “decorations” from the file names. Pressing Enter causes the deed to be done. The prompt appears unless there was an error.

Now folks, this is not for the faint of heart. If you have any hesitations in trying this, follow your instinct and pass it up! Try this only if you have some experience with this. I am not presenting a whole tutorial on DOS commands – that is beyond the scope if this post. I take no responsibility for any damage this might cause to your files, your hardware, or your self-esteem!

Well, that’s it. The files are renamed. The command window is closed by typing “exit” of clicking on the close-window “X”.

But wait, there is more!

Well running the command interpreter is a bit complicated. Is there an easier way? There is if you want to rename your photo files in a consistent manner. My way is to replace the “DSC” characters with my initials “LJK” and to drop anything after the photo “serial number”. This is done with a “batch file” you will appreciate how neat this is in a minute. First, here is how to buid the batch file:

Open Notepad (Start – type “notepad” and it will show up in the start menu). Now type the commands on separate lines. The first command is to go to the folder where the photo files are that are to be renamed. Here note an interesting command: “cd %1”. Instead of specifying the folders and subfolders this command used “%1” in place of the folder name. This specifies a runtime generated variable. When a folder name is passed to the batch file it is used in the command to go to that folder. The next command is the rename command just like before.


Now save this file. I like my user folder for the location, any place will do, but note where it is. Be careful in naming the file. image You can give it any name you like, but be sure the last part is “.bat“ – do not accept the “.txt“ default! I called my batch file “changeDSCfilename.bat”.

image image

Next locate the file using Windows Explorer. Right-click on the file and select Sent to then Desktop (create shortcut). That puts a beautiful shortcut on your desktop.

Now comes the neat part:

Open Windows Live Photo Gallery.  Keep you Photo Gallery window small enough so you can see part of your desktop and locate the newly created shortcut so you can see it. Make a folder for the photo files you want to rename, move those files to that folder. Point to the folder name in the navigation pane press the mouse button and drag the folder to the “rename” shortcut on the desktop. Release the mouse. You will see a short flash of the command prompt window and momentarily your photo files are renamed!

image image

Is this slick or what?!

So when you want to change the name of your photo files, just do this quick operation.

Related posts:

NOTE to Windows XP users:

The above procedures work just as well in XP. You have to keep in mind that the folder names and locations are a bit different. The “Pictures” folder is called “My Pictures” and is located inside the “My Documents” folder. See the illustration here (I did not make the “date” folder to keep this illustration simpler):




© 2010 Ludwig Keck



About Ludwig

Lending a helping hand where I can. . . My motto: If it is worth doing, it is worth doing well.
This entry was posted in Photo Gallery and tagged , , , . Bookmark the permalink.

8 Responses to Batch renaming of photo files

  1. Tyson says:

    You can also try <a href="">batch rename .exe</a>… It\’s a little more GUI friendly.

  2. Tyson says:

    You can also try <a href="">batch rename .exe</a>… It\’s a little more GUI friendly.

  3. Tyson says:

    You can also try batch rename .exe… It\’s a little more GUI friendly. (

  4. Tyson says:

    You can also try batch rename .exe… It\’s a little more GUI friendly. (

  5. Tyson says:

    You can also try batch rename .exe… It\’s a little more GUI friendly. (

  6. Tyson says:

    You can also try batch rename .exe… It\’s a little more GUI friendly. (

  7. Tyson says:

    You can also try batch rename .exe… It\’s a little more GUI friendly. (

  8. Natt Witham says:

    I would never have thought of going that deep into the system – I just select all of the photo files in Vista that I wish to rename at once, and than right-click on the first file in the line and click “rename”, then create the new name (for me usually the year-month-day date of the photo) and end with a (1). That renames all of the selected files quickly and gives them appropriate numbers as well.

Comments are closed.