0

I have a large amount of JPEGs inside subfolders that I need to rename to their current name with an extra 1 at the end.

For example:

G:\FILENAME\Subfolder1\subfolder2\JPEGNAME.JPG

Want to rename to

G:\FILENAME\Subfolder1\subfolder2\JPEGNAME1.JPG

I have over 900 files in this format that I need to rename.

Any help?

foxidrive
  • 40,353
  • 10
  • 53
  • 68
Mike
  • 3
  • 1
  • 1
    Welcome to SO! Have you made a first attempt yet? Let's see some code, then you're more likely to receive some help (even simple pseudo-code is better than nothing). – Kjartan Oct 15 '13 at 12:42
  • I have made my first attempt using the code below. My JPEG name is something like. 000010508298.JPG and running the following rename does nothing. I have tried something like echo rename *.JPG *1.JPG but it seems to chop off the end of my filename and renames the file to 0001051.JPG. – Mike Oct 15 '13 at 12:54

3 Answers3

1

edit I added /r as I see you have a tree of files to modify. Type this command in the main holding folder of the JPG files.

Here's a cmd prompt command. Delete the echo if you like what you see on the console.

for /r %a in (*.jpg) do echo rename "%a" "%~na1%~xa"
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • can you explain the "%a" "%~na1%~xa" part...I'm not that experienced with this language. Thanks – Mike Oct 15 '13 at 12:33
  • The for command uses a metavariable that can be a to z and A to Z and other characters. This is referred to here as %a (or %%a inside a batch file). It takes each filename in turn and the `%~n` returns the filename part while `%~x` returns the extension. They have the metavariable name added on the end, which is `a` here to become %~na and %~xa - read the last page of `FOR /?` to get a list of the modifiers. – foxidrive Oct 15 '13 at 12:49
  • Thanks for the quick responses everyone. I ended up using a tool Ifranview. – Mike Oct 15 '13 at 13:14
  • I also found a great program metamorphose2 that renames folders based on criteria. http://file-folder-ren.sourceforge.net/index.php?page=Download – Mike Oct 15 '13 at 13:58
0

There may not be a need for anything more than a simple REN command. See How does the Windows RENAME command interpret wildcards?.

As long as none of your file names have multiple dots in the name, then the following should work for the current directory. Just make sure there are at least as many ? as the longest name.

ren *.jpg ??????????????????????????????????????1.jpg

Or to process the entire directory tree

for /r %F in (.) do @ren "%F\*.jpg" ??????????????????????????????????????1.jpg

Or you can iterate each file with a FOR or FOR /R loop and rename them one at a time as foxidrive does in his answer.

Community
  • 1
  • 1
dbenham
  • 127,446
  • 28
  • 251
  • 390
0

using renamer:

$ renamer --find '/(.*)\.JPG/' --replace '$11.JPG' *

to operate recursively, change the * at the end of of the command to **.

Lloyd
  • 8,204
  • 2
  • 38
  • 53