Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  14] [ 0]  / answers: 1 / hits: 5375  / 2 Years ago, thu, may 26, 2022, 9:59:25

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?


More From » files

 Answers
1

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.


[#44674] Thursday, May 26, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alliulet

Total Points: 46
Total Questions: 109
Total Answers: 97

Location: Svalbard and Jan Mayen
Member since Sat, Oct 10, 2020
4 Years ago
;