Is there a way to rename multiple files in one command. In Windows, I am aware of the command

ren *.* *.jpg

Is there a similar command in Mac OS X that i could run, instead of hitting enter on each and every individual file and doing the renaming.

3 Answers 3


With unix-like systems, it's easier to use find

find ./  

(try this first to make sure that your list of files looks like what you were expecting

find ./ -exec mv ${} ${}.jpg \; 

This will append .jpg to the end of every file found. The regex for changing the final extension, rather than just appending, is left as an exercise for the reader.


While using find and for loops are efficient, Perl usually comes with /usr/bin/rename (in Linux at least) but I'm not sure you have it on MacOSX (at least not in my old 10.3).

If you don't have it, you can get this script from the CPAN. And this is how to use it:

$ ls
   tata.jpg  titi.jpg  toto.jpg  truc  tutu
$ rename -v 's/\.jpg$/.JPG/' *.jpg
   tata.jpg renamed as tata.JPG
   titi.jpg renamed as titi.JPG
   toto.jpg renamed as toto.JPG
$ ls
   tata.JPG  titi.JPG  toto.JPG  truc  tutu
  • rename is not installed on MacOS X 10.6.2 by default, either. It is a script I copied from the original Camel book - it was dropped (for lack of space) in later editions. I still use it for exactly such purposes. The only oddball thing to worry about it is the Mac's case-insensitive file system. Dec 29, 2009 at 1:48
  • For lack of space? /usr/bin/prename is hardly 3KB...
    – raphink
    Dec 29, 2009 at 6:58
  • Rather strange is that the man page for rename is in OSX but the function is not. Go figure.
    – BondedDust
    Aug 30, 2016 at 19:00

This will work (and leads to much more flexibility):

shopt -s extglob
for file in *.*; do mv ${file} ${file/%.*([^.])/.jpg}; done

There are also non-standard Unix command-line tools that can do the job more succinctly.

  • 1
    Isn't .* greedy? Without trying it, I'd guess it would move files.2009.12.28.pic to files.jpg, which could be very much the wrong goal Dec 28, 2009 at 21:41
  • D'Oh! you're right. I'll fix.
    – freiheit
    Dec 28, 2009 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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