Mac OS: How to batch edit file extension via Terminal

Today I had a directory of images whose file name extensions are .jpeg. I need them as .jpg but I didn’t want to rename them one by one.

Here’s how we can change the file extensions in a directory by batch. And by the way, I am on Mac OS El Capitan version 10.11.5 with Homebrew package manager.

First, open your Mac’s Terminal.

Type the command rename just to check if you have it installed in your system. If the Terminal displays usage instructions on rename then you already have it.

If rename is a command not found, then install it via Homebrew using this command:

Once the rename command is available, navigate to the directory where your files that need new extensions are.

Then edit the following command to suit your needs before running:

The syntax for this is actually rename "s/OLD_EXTENSION/NEW_EXTENSION/" *.OLD_EXTENSION

That’s all! I hope that worked for you.

Resource: Changing extension to multiple files

Related Posts:

Posts that may be related to "Mac OS: How to batch edit file extension via Terminal":


A Filipino programmer and baker. When I have time to spare, I blog, play video games, watch series (usually anime), cook dishes, draw, or spend a little time with pets. When I have the rare luxury of time, I get to travel and record song covers too! Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *