0

My camera only numbers photos using 4 digits, but I am now well into the 5 digit realm. So for thousands of photos, I would like to add a fifth digit. E.g. rename IMG_2450 to IMG_12450.

I did this before about a year ago using Command Prompt, but I'm having trouble replicating those results today.

I tried: ren IMG_.jpg IMG_1.jpg and variations like: ren IMG_????.jpg IMG_1????.jpg

But what ends up happening is that instead of adding the number 1, command prompt ends up replacing the first character of the existing string of numbers.

So, IMG_2450 becomes IMG_1450 rather than IMG_12450.

What am I doing wrong here?

2 Answers 2

1

Here's what you need. Run the following command:

for /f "tokens=1,2 delims=_" %a in ('dir /b img_*.jpg') do @echo ren "%a_%b" "%a_1%b"

If you're happy with the output, delete the @echo and run it again.

0

Try this:

FOR %v IN (IMG_*.jpg) DO REN %v 1%v

Source: http://www.lagmonster.org/docs/DOS7/z-ren1.html

4
  • Pretty sure last time I saw lfnfor was back in Win9x, and I doubt the OP's still using that.
    – Karan
    May 20, 2013 at 21:49
  • @Karan sorry, copied verbatim...
    – Kruug
    May 20, 2013 at 21:55
  • Command's still incorrect BTW; try it and see where the 1 ends up.
    – Karan
    May 20, 2013 at 22:04
  • 1
    Well, that might work if Michael is using Windows 95, 98, or Me, but Wikipedia says that those are the only versions of Windows that support the LFNFOR command. You might want to think twice before quoting from a page that refers to the Windows Command Prompt as “Dos” and refers to quotes as “inverted commas”. May 20, 2013 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .