Add File Extension Group of Files OS X
In this article
- Why You Might Need to Change File Extensions in Bulk
- Using Finder’s Built-In Batch Rename
- Using Terminal for Precise Control
- What Happens When You Change an Extension?
- Common Problems and How to Avoid Them
- Alternatives to Finder and Terminal
- Safety Tips When Changing Extensions in Bulk
- Frequently Asked Questions
To add a file extension to a group of files on macOS, you can select all the files in Finder, choose Rename from the context menu (or the File menu), and use the Format option to replace or append the extension. This method works for any number of selected files and is the quickest built-in way to change extensions in bulk.
Why You Might Need to Change File Extensions in Bulk
File extensions tell macOS which application should open a file. When you download a file and it arrives without an extension, or when you have a batch of files that were exported with the wrong extension, macOS may not open them correctly. For example, a text file saved as notes.txt opens in TextEdit, but if it is named notes with no extension, macOS may ask which app to use. Similarly, a batch of images from a camera might be named .jpeg when you need .jpg, or a set of HTML files might have been saved as .txt by mistake.
Renaming one file at a time is tedious. The Finder's built-in batch rename tool handles this in seconds, and it does not require any third-party software or command-line knowledge.
Using Finder’s Built-In Batch Rename
macOS has included a batch rename feature in Finder since OS X Yosemite (10.10). It works on any version of macOS from that point forward, including the latest versions. To add an extension to a group of files:
- Open Finder and navigate to the folder containing the files.
- Select the files you want to change. Click the first file, then hold the Shift key and click the last file to select a contiguous range. To select non-adjacent files, hold the Command key (⌘) while clicking each file.
- Right-click (or Control-click) on any selected file and choose Rename X Items from the context menu. Alternatively, with the files selected, go to the File menu and choose Rename X Items.
- In the pop-up window, click the drop-down menu on the left (which defaults to “Replace Text”) and choose Add Text.
- In the text field, type the extension you want to add, including the dot. For example, type
.txtor.jpg. - Use the second drop-down menu to choose After Name (this adds the text at the end of the filename, which is exactly what you need for an extension).
- Click Rename. The extension is added to every selected file.
If the files already have an extension and you want to replace it, choose Replace Text instead. Set “Find” to the old extension (for example, .txt) and “Replace with” to the new one (for example, .md). This replaces only that exact string, so be careful if the same text appears elsewhere in the filename.
Using Terminal for Precise Control
Finder’s batch rename is easy, but it has a limitation: it always adds the text after the entire filename. If your files already have an extension and you want to add a second one (for example, changing file.txt to file.txt.md), Finder will do that. But if you want to add an extension only to files that do not already have one, or if you need to handle thousands of files, the Terminal gives you more control.
The command-line tool rename is not installed by default on macOS, but you can use a simple loop with the built-in mv command. For example, to add .txt to every file in the current folder that does not already end with .txt:
for f in *; do if [[ $f != *.txt ]]; then mv "$f" "$f.txt"; fi; done
This loops through every file, checks if it already ends in .txt, and if not, renames it with .txt appended. You must run this from the folder containing the files. To do that, type cd and drag the folder onto the Terminal window, then press Return.
For a more robust solution, you can install the rename utility via Homebrew (brew install rename) and then use commands like:
rename -n 's/$/.txt/' *
The -n flag shows what would be changed without actually renaming, which is a good safety check. Remove -n to apply the changes.
What Happens When You Change an Extension?
Changing a file extension does not alter the file’s contents. It only changes the name. If you rename a JPEG image to .txt, the data is still a JPEG, but macOS will try to open it with a text editor, which will likely show garbled characters. The file is not corrupted, but it may be confusing.
macOS uses extensions to determine the default application, but it also checks the file’s actual type when possible. For example, if you rename a PNG file to .jpg, macOS may still recognize it as a PNG and open it with Preview, but some apps may complain. To avoid problems, only change an extension when you are sure the file’s format matches the new extension, or when you are converting the file with a dedicated tool.
If you want to change the file type itself (for example, from text to PDF), you need to use an application that can export or convert the file. Renaming alone will not convert it.
Common Problems and How to Avoid Them
- “You are about to change the extension” warning: macOS shows this dialog when you manually change an extension in the Get Info window. The batch rename tool does not show this warning, so double-check your settings before clicking Rename.
- Files with no extension: If a file has no extension, Finder’s “Add Text” with “After Name” works perfectly. If the file has an extension and you want to replace it, use “Replace Text” and be sure to include the dot (e.g.,
.txt). - Hidden files: Finder’s batch rename does not affect hidden files (those starting with a dot). To rename those, use Terminal.
- Case sensitivity: macOS is usually case-insensitive, but if you are on a case-sensitive filesystem (rare), renaming
File.TXTtoFile.txtmay require two steps to avoid a conflict. - Undo: If you make a mistake, press Command+Z immediately in Finder to undo the batch rename. This works in most cases, but not always if you have done other operations in between.
Alternatives to Finder and Terminal
If you frequently rename files in bulk, you might want a dedicated file renaming app. Popular options include Name Mangler, Renamer, and A Better Finder Rename. These apps offer more advanced features like regular expressions, sequential numbering, and the ability to preview changes before applying them. They are not free, but they can save time if you work with many files.
Another alternative is to use a cloud service or a script. For example, you can write a small AppleScript or use Automator to create a quick action that adds a specific extension to selected files. Automator is built into macOS and lets you create a right-click service without any coding.
Safety Tips When Changing Extensions in Bulk
- Back up first: Before renaming a large batch of files, copy them to a temporary folder or make a zip archive. A mistake can be hard to undo if you do not notice it immediately.
- Test on a few files first: Select two or three files, run the rename, and check the results before applying to the whole group.
- Do not rename system files: Changing extensions on files in system folders (like
/Systemor/Library) can break applications. Only rename files you own and understand. - Know your file format: If you are not sure what type a file is, use the
filecommand in Terminal (e.g.,file photo.jpg) to see the actual format. This helps you choose the correct extension.
Frequently Asked Questions
Can I add an extension to multiple files at once without using Terminal?
Yes. Select the files in Finder, right-click and choose Rename X Items, then use Add Text with After Name. This works for any number of files and does not require Terminal.
What if the files already have an extension and I want to change it?
Use Replace Text in the same batch rename window. Set “Find” to the current extension (including the dot) and “Replace with” to the new one. For example, replace .jpeg with .jpg.
Does changing the extension damage the file?
No. The file’s data remains unchanged. However, if the new extension does not match the actual file type, macOS may not open it correctly, and some applications may refuse to open it. Always verify the file type before renaming.
Why does Finder show “You are about to change the extension” when I rename a single file?
That warning appears when you change an extension in the Get Info window or when you rename a file and type a new extension manually. It is a safety measure to prevent accidental changes. The batch rename tool does not show this warning, so you must be careful.
Can I add extensions to files in subfolders as well?
Finder’s batch rename only works on the files you have selected in the current folder. It does not include subfolders. To include subfolders, use Terminal with a recursive loop, or use a third-party app that supports recursive renaming.
What is the difference between “Add Text” and “Replace Text” in Finder’s rename?
“Add Text” inserts text at the beginning or end of the filename without removing anything. “Replace Text” finds a specific string and replaces it with another. For adding an extension to files with no extension, use “Add Text” with “After Name”. For changing an existing extension, use “Replace Text”.