Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer

Try this:

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

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

share|improve this answer
    
Pretty sure last time I saw lfnfor was back in Win9x, and I doubt the OP's still using that. –  Karan May 20 '13 at 21:49
    
@Karan sorry, copied verbatim... –  Kruug May 20 '13 at 21:55
    
Command's still incorrect BTW; try it and see where the 1 ends up. –  Karan May 20 '13 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”. –  Scott May 20 '13 at 22:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.