I need to change the postfixes of all files (all the same .JPEG) to .jpeg (Capital vs. lower case).
Is there a quick way of doing so?

7 Answers 7


Use the Perl program rename which is installed by default:

rename 's/\.JPEG$/.jpeg/' *.JPEG

The first argument is a Perl regular expression matching filenames ending with .JPEG and replaces it with .jpeg.

The second argument selects the files that should be matched, in your case every file in the current directory ending on .JPEG. You could specify a different location of course:

rename 's/\.JPEG$/.jpeg/' ~/Pictures/*.JPEG

Other answers I've seen:

  • rename s/.JPEG$/.jpeg/ * - this will also rename files like StupidJPEG to Stupi.jpeg because the dot is matches any character. .JPEG$ is a regular expression
  • rename 's/\.JPEG$/\.jpeg/' * - works, but it's less efficient because it passes all files in the current directory to rename.
  • rename -n 's/.JPEG$/.jpeg/' *.JPEG - the -n option would show the files being renamed, without actually renaming them ("dry run"). Because *.JPEG matches files postfixed with .JPEG only, the dot-matches-all issue is non-existent here.
  • 1
    The second dot does not need to be escaped because it's not part of the matching expression. In a regular expression, . matches any character (with a few exceptions), therefore the dot needs to be escaped in the regular expression \.JPEG$.
    – Lekensteyn
    Jun 11, 2011 at 20:56
  • This also works: for i in *.JPEG; do mv $i $(basename $i .JPEG).jpeg; done
    – crazy2be
    Jun 11, 2011 at 23:43
  • @crazy2be: Make an answer of it. It's useful in case rename is not available. Also, $(basename $i .JPEG) can be replaced with ${i%%.JPEG} (bash extension)
    – Lekensteyn
    Jun 12, 2011 at 8:36

Although this is possibly not the best solution for this particular usage case,

for i in *.JPEG; do mv "$i" "$(basename "$i" .JPEG).jpeg"; done

also works. We can do some trickyness with bash in order to slightly increase efficiency (avoiding in invocation of an additional sub-process in the inner loop), ending up with:

for i in *.JPEG; do mv "$i" "${i%%.JPEG}.jpeg"; done

This solution is most useful if you want to do something else in additon to renaming the files, such as logging what names were changed, or even just doing a dry run to ensure that it does what you want.

  • I recommend putting the variables between double quotes, it's not uncommon for images to have spaces in their names.
    – Lekensteyn
    Jun 13, 2011 at 8:53
  • Done! I forgot about that, it worked in my test (files named 1-1000.JPEG sequentially) :P.
    – crazy2be
    Jun 14, 2011 at 4:39

There is a tool for this:

sudo apt-get install renameutils or click renameutils

(if not already installed)

where you can do (from command line):

rename s/\.JPEG$/\.jpeg/ *.JPEG


Found it a second after posting:

rename 's/\.JPEG$/.jpeg/' *
  • 1
    A small optimization, but for a large amount of files, my answer (and tgm's answer) are preferred because it sends less files to rename for parsing. * matches everything in a directory where *.JPEG would really match just the files postfixed with .JPEG.
    – Lekensteyn
    Jun 11, 2011 at 21:06

Use the rename command. It's different than move and often is causes confusion because it was specifically created with picture renaming in mind.

Something like this command should work (for all files that end in .JPEG, change .JPEG to .jpeg)

rename -n 's/.JPEG$/.jpeg/' *.JPEG


Doing things in parallel is getting more and more important, hence I recommend:

parallel mv {} {.}.jpg ::: *.JPG

This utility is not installed by default though.

  • Nice to know about this, but I really need something quick and Dirty, and do not really care for performance/efficiency Jun 12, 2011 at 11:33

If you are looking for a nice GUI solution and don't want to muck about with complicated command line arguments, there is a great Nautilus script available to rename files. It has a simple interface and many options.

Available here: http://gnome-look.org/content/show.php/Renamer?content=87601

You must log in to answer this question.

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