Find and replace across hundreds of filenames
Finder can replace text in many filenames at once, and for simple jobs it is enough. Here is how to use it, the four ways a find-and-replace rename goes wrong, and when you need patterns instead of plain text.
A client changed its name. A project code went from PRJ to P24. A camera stamped DSC_ on four hundred files you would rather call Wedding_. You need to change the same piece of text in hundreds of filenames, and you are not going to do it one at a time.
Finder can do this
Finder has a batch find-and-replace built in:
- Select the files.
- Right-click and choose Rename… (it says Rename N Items… with more than one selected).
- Change the first dropdown to Replace Text.
- Enter what to Find and what to Replace with.
- The example at the bottom shows the result for the first file. Click Rename.
For a clean, predictable change — DSC_ to Wedding_ across a folder of camera files — that is all you need, and it is worth knowing before reaching for anything else. Edit → Undo straight afterwards reverses it.
Four ways it goes wrong
The Replace Text option is literal: it replaces every occurrence of exactly that text. That is also where the trouble starts.
1. The text appears in more places than you think. Replacing 2023 with 2024 also changes Invoice_20231_draft, and the file named Budget 2023 vs 2023 actuals gets both replaced. With hundreds of files, the preview of a single example will not show you the one file that went wrong.
2. The extension is part of the name. Replacing jpg with photo in holiday_jpg_backup.jpg touches the extension too, and a file that ends .photo no longer opens with anything. Anything that appears in extensions — doc, pdf, mov — needs care.
3. Two files end up with the same name. Replace _final with nothing, and Report.pdf and Report_final.pdf collide. Finder will not overwrite a file, so the rename fails or stops partway — and now some files are renamed and some are not.
4. Text that looks the same is not. Filenames that came from a Windows PC, a website or a zip archive may use different characters from the ones you type — a different kind of dash, a non-breaking space, or an accented letter stored as a letter plus a separate accent. Find does not match, and nothing appears to happen.
When plain text is not enough
Many renames are not "change this text" but "change this shape":
- Swap
12-03-2024_Reportto2024-03-12_Reportso files sort by date. - Change
IMG_4821toHoliday_4821, keeping the number. - Remove everything in square brackets, whatever it says.
These need patterns, and the standard tool for patterns is the regular expression. They look intimidating but a few cover most jobs:
| Find | Replace | Does |
|---|---|---|
IMG_(\d+) |
Holiday_$1 |
keeps the number, changes the prefix |
(\d{2})-(\d{2})-(\d{4}) |
$3-$2-$1 |
day-month-year to year-month-day |
\s*\[.*?\] |
(nothing) | removes a bracketed tag and the space before it |
\s+ |
_ |
turns runs of spaces into one underscore |
The parentheses capture part of the match, and $1, $2 put it back. \d is a digit, \s a space, + means one or more.
Finder has no pattern support. The Terminal does, with rename from Homebrew or a short loop, but a Terminal rename has no preview, and a mistake in a pattern is applied to every file at once.
A safe routine, whatever the tool
- Work on a copy the first time you run a new pattern.
- Restrict what the rule touches — the name only, not the extension.
- Look at every result, not just the first one. Sort the preview so anything unusual stands out.
- Check for collisions before you apply, not after.
Where RenameDeck fits
RenameDeck is a batch renamer for Mac built around that routine.
Its Replace rule works with literal text, wildcards or regular expressions, and you choose whether it targets the name, the extension, the full name or the path — so problem two simply does not arise. You see a complete list of proposed names before anything changes, and can search it, which is how you find the one Invoice_20241_draft among four hundred files. Invalid names and collisions are flagged before you apply, and RenameDeck never overwrites an existing file.
Rules stack, so replace, case, whitespace and numbering can be combined into one recipe and saved for next time. Renames are journaled, including swaps and case-only changes, and history offers undo while the renamed file is still the one it renamed.
It is sandboxed with no network entitlement, account, analytics or tracking. Filenames never leave your Mac. It requires macOS 14 or later.