Batch Rename Files in Mac OS X: A How-To Guide
In this article
To batch rename files in macOS, use the built-in Rename Items feature in Finder, which lets you rename multiple files at once without any extra software. This guide shows you how to use it, along with alternative methods and troubleshooting tips.
Why Batch Rename Files on a Mac?
Renaming files one by one is tedious and time-consuming, especially when you have dozens or hundreds of files that need consistent naming. Batch renaming helps you:
- Add a prefix or suffix to a group of files (e.g., "vacation_" + photo names).
- Replace a specific text string in filenames (e.g., change "IMG" to "Photo").
- Convert filenames to a common format, like changing spaces to hyphens.
- Add a sequential number to files for ordering (e.g., "01", "02", "03").
This saves time and reduces errors, especially for photographers, designers, and anyone organizing large file collections.
How to Batch Rename in Finder (Built-in Method)
macOS includes a simple yet powerful batch rename tool right in Finder. Here's how to use it:
- Open a Finder window and navigate to the folder containing the files you want to rename.
- Select all the files you want to rename. You can click the first file, then hold Shift and click the last file to select a range, or hold Command and click individual files to select non-contiguous ones.
- Right-click (or Control-click) on any selected file and choose Rename X Items (where X is the number of selected files).
- A small pop-up window appears with a dropdown menu at the top. Choose one of the options:
- Replace Text: Find a specific text string in the filenames and replace it with something else. For example, find "IMG" and replace with "Vacation".
- Add Text: Add text to the beginning or end of each filename. You can also choose to add text before or after the extension.
- Format: Rename files with a custom name and an optional sequence number. You can set the name, the starting number, and the number of digits (e.g., 1, 01, 001).
After choosing an option, fill in the fields and click Rename. The files are renamed instantly. You can undo with Command+Z if you make a mistake.
Using Terminal for Advanced Batch Renaming
For more complex renaming tasks, the Terminal app gives you full control. The mv command can rename a file, and with a loop or the rename command (if installed), you can batch rename. However, the built-in Finder tool covers most needs. Here's a simple example using a loop to add a prefix to all .txt files in a folder:
cd ~/Documents/folder for f in *.txt; do mv "$f" "prefix_$f"; done
This changes file1.txt to prefix_file1.txt, and so on. Be careful with spaces and special characters—always quote the variable. The rename command is not preinstalled, but you can install it via Homebrew (brew install rename) for even more powerful regex-based renaming.
Third-Party Batch Rename Tools
If you need features beyond Finder's built-in tool, several third-party apps exist. They offer advanced options like:
- Regular expression support for complex pattern matching.
- Preview of the new names before applying.
- Handling of metadata (e.g., renaming photos by date taken).
- Batch renaming across nested folders.
Popular options include Name Mangler, A Better Finder Rename, and Renamer. These are paid apps, but they offer trial versions. For most users, the Finder tool is sufficient, so try it first before spending money.
Common Problems and How to Avoid Them
Batch renaming can go wrong if you're not careful. Here are common pitfalls and how to avoid them:
- Accidentally renaming the extension: In Finder's Add Text option, make sure you select "after name" rather than "after extension" if you don't want to change the file type. Changing the extension can make files unopenable.
- Duplicate names: If you rename files to the same name, macOS will ask if you want to replace the existing file. This can lead to data loss. Always preview the new names if using a third-party tool, or double-check your pattern.
- Undo not working: If you close the Finder window or perform other actions, undo may not revert the renaming. It's safer to test on a copy of a few files first.
- Files in iCloud Drive: If the files are stored in iCloud Drive and not downloaded locally, renaming might fail or take time. Ensure files are downloaded before renaming.
How to Choose the Right Method
Your choice of method depends on your needs:
- Simple prefix/suffix or replacing text: Use Finder's built-in tool. It's fast and doesn't require any learning curve.
- Adding sequential numbers: Finder's Format option is perfect for this. You can set the start number and the number of digits.
- Complex patterns or regex: Use a third-party tool or Terminal with the
renamecommand. This gives you the most control but requires some technical knowledge. - Renaming files based on metadata (like photo dates): A third-party tool is usually necessary, as Finder doesn't support this.
For 95% of users, the built-in Finder tool is all you need. It's free, fast, and reliable.
Safety Tips and Best Practices
Renaming files is generally safe, but you can lose data if you're careless. Follow these tips:
- Back up important files before a large batch rename. Time Machine or a simple copy to another folder works.
- Test on a few files first to ensure the pattern works as expected.
- Never rename system files or files in system folders (like /Library or /System). This can break your Mac.
- Be cautious with extensions—only change them if you know what you're doing.
- Use undo immediately if something looks wrong. The undo command (Command+Z) works in Finder for the last rename action.
Frequently Asked Questions
Can I batch rename files with different extensions?
Yes, Finder's Rename Items works on any selected files, regardless of extension. However, be careful if you use the Format option, as it will rename all selected files with the same new name and sequence, potentially removing their original extensions. If you want to keep extensions, use Replace Text or Add Text instead.
How do I rename files with numbers in order (e.g., 01, 02, 03)?
In Finder, select the files, right-click, choose Rename X Items, then select Format. Set the Name Format to Name and Counter, enter a base name (e.g., "vacation"), set the Start Number to 1, and choose the number of digits (e.g., 2 for 01, 02, etc.). Click Rename.
Why is the Rename option grayed out in Finder?
The Rename option is grayed out if you have selected only one file, or if the files are in a location where you don't have write permissions (like certain system folders or a read-only network volume). Make sure you have permission to modify the files and that you've selected at least two files.
Can I undo a batch rename?
Yes, you can undo the last rename action by pressing Command+Z in Finder. However, if you perform another action (like moving files) or close the Finder window, the undo may not work. It's best to undo immediately.
Does batch renaming work on external drives or cloud storage?
Yes, it works on external drives and cloud storage folders (like Dropbox or Google Drive) as long as the files are accessible and you have write permissions. For iCloud Drive, ensure the files are downloaded locally (not just in the cloud) before renaming.
What's the difference between renaming and moving files?
Renaming changes the name of the file, while moving changes its location. In Finder, you can do both by dragging files to a new folder while holding Command (to move), but renaming is done via the Rename Items feature. They are separate operations.