I have several hundreds .jpg Images. The problem is, that some have ".jpg" and others have ".JPG" as the file-extension.

I'm on Windows 7, 64 bit. How can I easily change all file-extensions to the same name (".jpg" in this case)? Is there some kind of commandline-command?

link|improve this question

50% accept rate
feedback

3 Answers

up vote 4 down vote accepted

from a command prompt in the directory: ren *.* *.jpg

link|improve this answer
Or to be more specific: ren *.jpg *.jpg – Dennis Williamson Jan 18 '11 at 0:33
feedback

To do it recursively:

for /r %f in (*.jpg) do rename "%f" "%~nf.jpg"

or

for /r %f in (*.jpg) do rename "%f" "*.jpg"
link|improve this answer
feedback

A powershell way:

get-childitem | where {$_.name -match 'JPG'} | %{rename-item -path $_ -newname "$($_.basename).jpg"}

Edit: Requested explanation

The get-childitem is much like the old 'dir' command.

where is actually an alias for where-object and is a filtering cmdlet

The percent sign (%) is an alias for the cmdlet foreach-object, which performs a for loop for each item that it is passed.

rename-item is pretty self explanatory. :)

The $_ you see is a special symbol for "THIS." "THIS" is whatever object it is working on at the time.

So in plain English:

"Get the files in the current folder that contain 'JPG.' For each of those, rename them with the original base name, and add '.jpg' to the end."

update: Stumbled across THIS on stackoverflow. Looks like it would fit the bill.

link|improve this answer
Can you explain what this command does in some detail? – Zypher Jan 18 '11 at 2:55
Updated just for you, Zypher :D – JakeRobinson Jan 18 '11 at 6:15
ooh fail... I just tried it and powershell doesn't understand caps!? hrmm. – JakeRobinson Jan 18 '11 at 6:29
feedback

Your Answer

 
or
required, but never shown

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