How To: Bulk Rename File Extensions With Terminal/Shell

Lets say you have a bunch of .jpg files that you know are actually .rar files.

What would be the simplest way to rename them all?

First you’d navigate to the directory that contains the .jpg files with the “cd” command

For brevity lets assume the only .jpg files in this directory are .jpg files that you want to change

All you have to do is run this command

mv *.jpg *.rar

And all the .jpg files will have been renamed to .rar

If you want to learn more about the “mv” command just type in

man mv

One response to “Mac and Linux Tip: Bulk Rename File Extensions With Terminal and/or Shell”

  1. Karsta Avatar
    Karsta

    Does not work:
    $ mv *.JPG *.jpg
    mv: target `*.jpg’ is not a directory

    $ ls -1
    P1010869.JPG
    P1010871.JPG
    P1010872.JPG
    P1010877.JPG
    P1010878.JPG
    P1010882.JPG
    P1010888.JPG
    P1010889.JPG
    P1010891.JPG

Leave a reply to Karsta Cancel reply

I’m Erik

Artsy on the weekends. Accountant on the weekdays