Batch Change File Extensions on Mac: A How-To
In this article
- Why You Might Need to Batch Change Extensions
- Method 1: Using Finder (Built-in, No Extra Software)
- Method 2: Using Terminal (For Power Users and Complex Rules)
- Method 3: Using a Third-Party App (For Advanced Features and GUI)
- Common Problems and How to Avoid Them
- What About Converting the File Format?
- Frequently Asked Questions
Yes, you can batch change file extensions on a Mac, and the built-in Finder app is the quickest way for most files. This article explains the built-in method, the Terminal approach for more control, and the situations where a dedicated app is worth considering.
Why You Might Need to Batch Change Extensions
File extensions are the suffix after the dot in a filename (like .jpg, .pdf, or .txt). They tell macOS which app should open the file. There are several legitimate reasons to change them in bulk:
- You exported a batch of files with the wrong extension (e.g., a script saved them as
.txtwhen they are actually.csv). - You need to convert a set of image files from one format to another, and the contents are already in the target format (e.g., renaming
.jpegto.jpg). - You have a collection of files that a program expects to have a specific extension, even if the data inside is plain text.
Before proceeding, a crucial warning: changing an extension does not convert the file's contents. Renaming a .png to .jpg does not make it a JPEG image; it only changes the label. The file will likely be unreadable or open incorrectly. Always back up files before batch renaming, especially if you're not 100% sure of the format.
Method 1: Using Finder (Built-in, No Extra Software)
Finder's built-in rename feature is the safest and easiest way for most users. It works on all files in a selected folder, and it's completely free.
- Open Finder and navigate to the folder containing the files.
- Select all the files you want to rename. You can click the first one, then hold Shift and click the last one to select a range, or hold Command (⌘) and click individual files.
- Right-click (or Control-click) on one of the selected files and choose Rename X Items (where X is the number of selected files).
- In the drop-down menu at the top of the pop-up, choose Replace Text.
- In the first text field, type the current extension including the dot (e.g.,
.jpeg). - In the second text field, type the new extension including the dot (e.g.,
.jpg). - Click Rename.
This method replaces the text in the filename. If you type .jpeg in the first field, it will only replace that exact string. This is perfect for extensions. If you have files with different extensions, you'll need to run the process multiple times, once for each extension.
Method 2: Using Terminal (For Power Users and Complex Rules)
Terminal gives you more control and can handle thousands of files at once. It's also useful if you need to add a prefix or suffix, or change extensions based on a pattern. Here are a few common commands.
Change extension for all files of a specific type in the current folder:
for f in *.jpeg; do mv "$f" "${f%.jpeg}.jpg"; doneThis loops through every file ending in .jpeg and renames it to have a .jpg extension. The ${f%.jpeg} part removes the .jpeg from the end of the filename, and then we append .jpg.
Change extension for all files regardless of current extension:
for f in *; do mv "$f" "${f%.*}.txt"; doneThis renames every file in the folder to have a .txt extension, stripping whatever extension it had before. Be very careful with this one.
Add a prefix to all files:
for f in *; do mv "$f" "prefix_$f"; done
To use Terminal, open it from Applications > Utilities, then type cd followed by a space, drag the folder from Finder into the Terminal window, and press Return. Then paste the command you want and press Return.
Method 3: Using a Third-Party App (For Advanced Features and GUI)
If you find Terminal intimidating or need features like renaming based on file metadata (e.g., date taken), a dedicated app is a good option. There are several free and paid apps on the Mac App Store that offer batch renaming. These apps typically provide a visual interface where you can build a rule set, see a preview of the new names, and then apply the changes. They are especially useful when you need to combine multiple rules (e.g., change extension AND add a date).
However, for the simple task of changing extensions, the built-in Finder method is usually sufficient and avoids installing extra software.
Common Problems and How to Avoid Them
Here are the most frequent issues people run into when batch changing extensions:
- Files become unreadable. As mentioned, this happens when you change the extension to something that doesn't match the actual file type. For example, renaming a
.docxto.pdfwill not make it a PDF. You need to actually convert the file using an app like Preview or a dedicated converter. - Finder shows a warning. If you try to change the extension of a single file in Finder, it will ask you to confirm. When you batch rename, you don't get that warning, so you must be extra careful.
- The extension doesn't appear to change. By default, Finder hides file extensions. To see them, go to Finder > Settings > Advanced and check the box for Show all filename extensions. This is essential before you start renaming, so you can see what you're doing.
- You accidentally rename the whole filename. In Finder's Replace Text feature, if you type the extension without the dot, or if the extension appears elsewhere in the filename, you might replace more than you intended. Always include the dot and double-check the preview.
What About Converting the File Format?
If you actually need to convert the file's contents (e.g., from .png to .jpg), you need to use a conversion tool. On macOS, you can often do this with built-in apps:
- Images: Open the image in Preview, then go to File > Export, choose the new format, and save. You can also select multiple images in Preview and export them all at once.
- Documents: Many apps like Pages or TextEdit can export to different formats. For example, you can save a Pages document as a Word file.
- Audio/Video: The built-in Music app or QuickTime Player can convert some formats. For more advanced conversions, you may need a third-party app.
Remember, changing the extension is just renaming the file. Converting the format changes the data inside.
Frequently Asked Questions
Can I undo a batch rename in Finder?
Yes, you can undo the last rename action by pressing Command (⌘) + Z immediately after performing the rename. This works for both Finder and Terminal (as long as you haven't closed the Terminal window). If you've done other actions since, you may not be able to undo it, so it's best to test on a small group of files first.
Why does Finder hide extensions by default?
Apple hides extensions to make filenames look cleaner and less technical. This is a design choice, but it can be confusing when you need to work with files. You can turn this off in Finder Settings as described above. Even with them hidden, macOS still uses the extension to determine the file type.
Will changing an extension from .jpeg to .jpg break anything?
No, .jpeg and .jpg are the same format, just different abbreviations. macOS handles both identically. This is a common and safe batch rename. Similarly, .htm and .html are the same.
Can I batch change extensions for files in subfolders?
Finder's built-in rename only works on the files you have selected in the current folder. It does not automatically include subfolders. In Terminal, you can use the find command to target files in subfolders, but that's more advanced. A third-party app is often easier for this scenario.
Is it safe to change an extension to .txt to see what's inside?
Yes, this is a common trick. If you have a file with an unknown extension, you can copy it, change the copy's extension to .txt, and open it in TextEdit. You'll see the raw data, which can help you identify the format (e.g., you might see %PDF at the start for a PDF). Just remember to work on a copy, not the original.