Sub topic 16
Renaming many files at once
This chapter assumes you can select several items in the Finder, use the Control-click (right-click) menu, and know how a folder holds files. You should also have read the earlier chapters on naming items and moving and copying them. The goal is to rename dozens of files in one step, predict what the result will be, and recover if it goes wrong.
Why batch rename exists
Renaming one file is simple: select it, press Return, type a name. Doing this for 80 photos from a camera named IMG_4821.JPG, IMG_4822.JPG and so on is slow and error-prone. The Finder has a built-in batch rename tool. It works on whatever you have selected and shows a live preview of the first new name before you commit.
The tool offers three modes:
| Mode | What it does | Typical use |
|---|---|---|
| Replace Text | Finds a piece of text in each name and swaps it for other text | Fix a typo, drop `IMG_`, change `draft` to `final` |
| Add Text | Inserts text before or after the existing name | Add a date prefix or a `_v2` suffix |
| Format | Discards the old name and builds a new one from a pattern with a counter | Name a series `Holiday 1`, `Holiday 2`, ... |
Opening the tool
- Open the folder and select the files. Use Command-A for everything, Command-click to add or remove single items, or Shift-click for a range.
- Control-click one of the selected items. Choose Rename N Items…, where N is the number selected.
- Pick a mode from the pop-up menu at the top of the dialog.
- Check the Example line, which shows how the first selected file would be named.
- Click Rename.
If you choose Rename while only one item is selected, you get the ordinary single-file rename instead. The batch tool appears only when two or more items are selected. You can also reach it from the File menu or from the Action button (the circle with three dots) in the toolbar.
Replace Text
Replace Text takes two fields: Find and Replace with. Every selected name that contains the Find text is changed. Names that do not contain it are left alone.
Example: a folder holds IMG_0101.JPG to IMG_0140.JPG. You want Lisbon_0101.JPG and so on. Enter IMG in Find and Lisbon in Replace with. Every occurrence of IMG in each name is replaced.
Points to check:
- Matching is by text, not by whole word. Replacing
awithbchanges everyain every name, not only standalone ones. - The extension is part of the name for matching purposes. If you replace
JPGwithjpg, the extension changes too, which is usually what you want. - Leaving Replace with empty deletes the Find text. This is the quickest way to strip a repeated phrase such as
copyfrom names.
Add Text
Add Text inserts a string and lets you choose before name or after name. "After name" places the text before the extension, so report.pdf with _final becomes report_final.pdf, not report.pdf_final.
A date prefix is a good use. Adding 2026-11-27 (note the trailing space) before the name turns Invoice.pdf into 2026-11-27 Invoice.pdf. Dates written year first sort chronologically under Name sorting, which supports the naming scheme you design in the final chapter.
Format
Format discards the old name and builds a new one. You choose three things:
- Name Format: Name and Index, Name and Counter, or Name and Date.
- Where: whether the number or date goes before or after the custom name.
- Custom Format: the text you type, such as
Lisbon.
You can also set Start numbers at, for example 1 or 101.
The three formats differ as follows:
| Name Format | Example result (custom text "Lisbon", start at 1) |
|---|---|
| Name and Index | `Lisbon 1`, `Lisbon 2`, `Lisbon 3` |
| Name and Counter | `Lisbon 0001`, `Lisbon 0002`, `Lisbon 0003` |
| Name and Date | `Lisbon 2026-11-27 at 12.16.54` style names |
Counter pads the number with zeros, which keeps files in the right order when sorted by name. With plain Index, Lisbon 10 sorts before Lisbon 2 in some contexts and with some tools. Prefer Counter for sets larger than nine files.
The Format mode keeps the original extension. You do not need to type .jpg.
Edge cases and common errors
Name collisions. Two files in one folder cannot share a name. If your rule would create duplicates, for example removing a differing prefix from A-notes.txt and B-notes.txt, the Finder warns you and does not rename. Change the rule or rename in smaller groups.
Selecting the wrong files. The tool changes only the selection. If the folder contains subfolders and you press Command-A, the folders are renamed too. Switch to List view or use the Kind sort order to select only files.
Hidden extensions. If extensions are hidden, you may not see what Replace Text will match. Open Finder > Settings > Advanced and turn on Show all filename extensions before you start.
Files in use or locked. A file that is locked in Get Info, or that you lack permission to change, is skipped or triggers an error. Close the app that has the file open and try again.
Synced folders. In iCloud Drive, renaming many files triggers many sync events. Allow time for the cloud icons to finish before moving the files elsewhere.
Undoing a batch rename
Press Command-Z straight after renaming. The Finder reverts the whole batch in one step, and the Edit menu shows Undo Rename Items. This works only while the Finder remembers the action. If you have quit and relaunched the Finder, or done many further operations, undo may no longer be available. For a large or important batch, duplicate the folder first (Command-D) and work on the copy.
Doing the same in Terminal
The Finder tool cannot do pattern rules such as "remove the first four characters". For those, Terminal (zsh) can help. This loop adds a prefix to every .jpg file in the current folder:
for f in *.jpg; do mv -n -- "$f" "2026-Lisbon-$f"; doneThe -n option stops mv from overwriting an existing file, and -- stops names that start with a dash from being read as options. The quotes keep names with spaces intact. Test on a copy of the folder, because mv has no undo.
Choosing a method
| Situation | Best choice |
|---|---|
| Fix a repeated word or typo | Replace Text |
| Add a date or version label | Add Text |
| Name a fresh set of photos in sequence | Format with Counter |
| Rule based on position or pattern | Terminal, or a dedicated rename app |
Exercise
A folder holds 120 photos named IMG_0001.JPG to IMG_0120.JPG. You want them named Lisbon 001.JPG, Lisbon 002.JPG and so on, in the order they were taken. Which mode and settings do you use, and what should you do before selecting the files?
Show answer
Sort the folder by Date Created (or Name, if the numbers already follow shooting order) so the numbering follows that order. Select all the files, Control-click, and choose Rename 120 Items. Pick Format, set Name Format to Name and Counter, put the counter after the name, enter Lisbon as the custom format, and start numbers at 1. Check the Example line, then click Rename. Command-Z undoes the batch if the result is wrong.
Exercise
You use Add Text to put _final after the name of report.pdf. What is the new name, and why?
Show answer
report_final.pdf. The Finder inserts the text before the extension, so the file type is preserved.