Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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

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

To do it recursively:

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


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

A powershell way:

get-childitem | where {$ -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.

share|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

Your Answer


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.