bulkrename
.com

How to Batch Rename Files on a Mac

Updated

macOS has a capable batch rename tool built into the Finder, and most people never find it because it only appears when several files are selected. This guide covers renaming a single file, the Finder rename dialog for many files, Automator and Shortcuts for jobs you repeat, and the Terminal for everything else.

How to rename a single file on Mac

  1. Click the file once in the Finder or on the desktop to select it.
  2. Press Return. The name becomes editable; macOS selects the name without the extension.
  3. Type the new name and press Return again.

Alternatively Control-click the file and choose Rename. A name may not contain a colon (:) and may not start with a dot, because names starting with a dot are hidden files. If you change the extension, the Finder asks whether you really want to; the file content is not converted.

Batch rename files in the Finder

  1. Open the folder and switch to List view (Command+2). Sort by the column you want the numbering to follow, for example Name or Date Created. The Finder numbers files in the order they are shown in the window, not in the order you clicked them.
  2. Select the files: Command+A for all, or Command-click single files.
  3. Control-click one of the selected files and choose Rename.
  4. In the dialog, choose Replace Text, Add Text or Format from the pop-up menu (see below).
  5. Check the example at the bottom of the dialog and click Rename.

If the result is wrong, choose Edit › Undo or press Command+Z right away; the Finder restores all the old names at once.

Replace Text

Enter the text to find and the text to put in its place. Leave Replace with empty to delete text, for example to remove Screenshot from the start of every name. Matching ignores upper and lower case. Short search strings can match more than you expect, so use whole words where you can.

Add Text

Adds your text before or after the current name. After the name means before the extension: report.pdf with _signed becomes report_signed.pdf. This is the quickest way to add a date or project code to existing names.

Format

Replaces the names completely with your text (the Custom Format field) and a number or date. Name and Index adds 1, 2, 3 and so on. Name and Counter adds a five-digit counter (00001, 00002), which keeps the files in order in every program. Name and Date adds the current date and time. You choose whether the number goes before or after the text and which number to start with.

Turn on extensions to see exactly what changes: Finder › Settings › Advanced › Show all filename extensions.

Automator and Shortcuts for repeated jobs

If you rename the same kind of files regularly, save the steps as a Quick Action that appears in the Finder's right-click menu.

  • Automator still ships with macOS. Create a new document of the type Quick Action, set it to receive files or folders in Finder, and add the action Rename Finder Items. It offers more modes than the Finder dialog: add date or time, add text, change case, make sequential, replace text and name a single item. Automator offers to add a Copy Finder Items step first, so the action can work on copies.
  • Shortcuts has a Rename File action. Combine it with Repeat with Each to rename every file passed to the shortcut, and enable it as a Quick Action in the shortcut's details so it shows up in the Finder.

Rename files with the Terminal

The Terminal is useful when the rule is more complex than the Finder can express. The default shell on current macOS versions is zsh; the loops below work in zsh and bash. Change to the folder first, for example cd ~/Pictures/Lisbon.

Change the extension .jpeg to .jpg:

zsh / bash
for f in *.jpeg; do
  mv -n -- "$f" "${f%.jpeg}.jpg"
done

${f%.jpeg} is the name with .jpeg removed from the end. -n stops mv from overwriting a file that already exists, and -- protects names that start with a dash.

Number all JPG files as lisbon_001.jpg, lisbon_002.jpg and so on, in alphabetical order:

zsh / bash
n=1
for f in *.jpg; do
  mv -n -- "$f" "$(printf 'lisbon_%03d.jpg' "$n")"
  n=$((n + 1))
done

zsh also ships zmv, a batch rename function with pattern syntax. Load it once per session, preview with -n, then run it without:

zsh
autoload -U zmv
zmv -n '(* *)' '${1// /_}'   # preview: spaces become underscores
zmv '(* *)' '${1// /_}'
zmv '(*).jpeg' '$1.jpg'      # .jpeg becomes .jpg

Commands in the Terminal cannot be undone with Command+Z. Try them on a copy of the folder first, or replace mv with echo mv to print what would happen.

Renaming without changing the originals

If you need renamed copies, for example to send photos with tidy names while keeping the camera originals, the online bulk renamer on bulkrename.com works in Safari, Chrome and Firefox on the Mac. It reads the files in the browser, applies a pattern such as lisbon_[num] and saves the renamed copies as a ZIP. For the same job on other systems, see how to rename multiple files at once.