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?
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?
Use the Perl program
rename
which is installed by default: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:Other answers I've seen:
rename s/.JPEG$/.jpeg/ *
- this will also rename files likeStupidJPEG
toStupi.jpeg
because the dot is matches any character..JPEG$
is a regular expressionrename 's/\.JPEG$/\.jpeg/' *
- works, but it's less efficient because it passes all files in the current directory torename
.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.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
Although this is possibly not the best solution for this particular usage case,
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:
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.
Found it a second after posting:
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:
This utility is not installed by default though.
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