Mac hosting guide

Batch Rename Files with Finder on a Rented Mac

Use Finder's Rename Items panel for small, simple batches. For anything over about 20 files, run the preview-only Python script below, review its plan, then apply. It never renames anything on its own.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

For a small, simple batch, select the files in Finder, Control-click and choose Rename Items. For anything over about 20 files, or any batch with collision risk, run the preview-only Python script below, read its plan, then apply. The script writes a manifest and an apply script. It never renames anything on its own.

Which rename method should I use?

Use the simplest method that lets you check the result.

ApproachBest forInstall
Finder Rename Items panelSimple find/replace, prefixes, numbered formatsBuilt in
Terminal for loop with mv -nPattern renames, extension changes, zero-padded countersBuilt in
Python 3 manifest (below)Any batch over about 20 files, or anything with collision riskInstall Python 3 and check python3 --version

Finder Rename Items. Select the files, Control-click the selection and choose Rename N Items…. The panel offers Replace Text (find and replace across names), Add Text (prefix or suffix) and Format (name plus a counter, index or date). ⌘Z undoes the batch if you catch a mistake in the same Finder session. Finder shows no collision preview, so reserve it for small, uniform selections you can check by eye.

Naming convention. Before you run anything, write down the target shape: lowercase or title case, separator (_ or -), date format (YYYYMMDD), zero-padding width, and whether extensions are normalised (.jpeg to .jpg). A manifest tells you whether the mapping is consistent. It cannot tell you whether the convention is the one you wanted.

Terminal for loop. Use mv -n (or mv -i) so an unrelated target cannot be silently overwritten, and quote every variable:

# Add a prefix to all JPEGs in the current directory
for f in *.jpg; do mv -n -- "$f" "product_$f"; done

# Change extension from .jpeg to .jpg
for f in *.jpeg; do mv -n -- "$f" "${f%.jpeg}.jpg"; done

A loop does not catch two source names that rename to the same target. macOS's default APFS volume is case-insensitive, so Report.PDF and report.pdf collide even though they look distinct. The manifest below checks for that. Homebrew's rename is a Perl-flavoured one-liner that suits already-reviewed renames once the plan is approved.

How do I get the files onto the Mac?

Pull a working copy from your own storage, and keep the originals untouched at the source. Copy over SSH with scp or rsync, or pull from your artifact store, Git host, object storage, SFTP endpoint or signed download URL from inside the Mac. Write down the exact pull command and where its credentials come from before you start. That pre-rename copy is also your recovery path.

How does the preview-only Python manifest work?

The script reads a directory, applies a Python regular-expression substitution in memory and writes two files:

  • rename-manifest-<timestamp>.tsv: one row per file with OLD, NEW and STATUS.
  • rename-apply-<timestamp>.sh: one mv -n -- per approved row, written only when the plan has zero rejected rows.

It needs Python 3.9 or later. Copy it to the Mac, run it against a copy of your data, read both files, then decide whether to apply.

#!/usr/bin/env python3
"""rename_manifest.py - preview-only rename planner (no renames performed).

Usage:
    python3 rename_manifest.py <directory> <python-regex> <replacement>

Example:
    python3 rename_manifest.py ./copy '^IMG_(\\d+)' 'Photo_\\1'
"""
from __future__ import annotations
import re, sys, time
import shlex
from pathlib import Path

BAD_CHARS = set("/\x00")            # path separator and NUL are never valid in a name
STAMP = time.strftime("%Y%m%d-%H%M%S")

def plan(directory: Path, pattern: str, replacement: str) -> list[tuple[str, str, str]]:
    rx = re.compile(pattern)
    rows: list[tuple[str, str, str]] = []
    seen_ci: dict[str, str] = {}    # case-folded target -> first OLD name that claimed it
    for entry in sorted(p.name for p in directory.iterdir() if p.is_file()):
        new = rx.sub(replacement, entry)
        if new == entry:
            rows.append((entry, new, "SKIP_NO_MATCH"));                       continue
        if not new or new in (".", ".."):
            rows.append((entry, new, "REJECT_EMPTY_OR_DOT"));                 continue
        if any(c in BAD_CHARS for c in new):
            rows.append((entry, new, "REJECT_PATH_SEPARATOR_OR_NUL"));        continue
        key = new.casefold()        # macOS default FS is case-insensitive
        if key in seen_ci:
            rows.append((entry, new, f"REJECT_COLLISION_WITH:{seen_ci[key]}"));continue
        target = directory / new
        if target.exists() and target.name != entry:
            rows.append((entry, new, "REJECT_TARGET_EXISTS"));                continue
        seen_ci[key] = entry
        rows.append((entry, new, "OK"))
    return rows

def write_artifacts(directory: Path, rows: list[tuple[str, str, str]]) -> None:
    manifest = Path(f"rename-manifest-{STAMP}.tsv")
    with manifest.open("w", encoding="utf-8") as fh:
        fh.write("OLD\tNEW\tSTATUS\n")
        for old, new, status in rows:
            fh.write(f"{old}\t{new}\t{status}\n")
    rejected = [r for r in rows if r[2].startswith("REJECT")]
    ok       = [r for r in rows if r[2] == "OK"]
    print(f"Manifest : {manifest}")
    print(f"OK rows  : {len(ok)}")
    print(f"Rejected : {len(rejected)}")
    if rejected:
        print("No apply script written. Resolve rejections, then re-run.")
        sys.exit(1)
    apply_path = Path(f"rename-apply-{STAMP}.sh")
    with apply_path.open("w", encoding="utf-8") as fh:
        fh.write("#!/usr/bin/env bash\nset -euo pipefail\n")
        fh.write(f"cd -- {shlex.quote(str(directory))}\n")
        for old, new, _ in ok:
            # mv -n refuses to overwrite; shell-quote both sides.
            fh.write(f"mv -n -- {shlex.quote(old)} {shlex.quote(new)}\n")
    apply_path.chmod(0o755)
    print(f"Apply    : {apply_path}  # review before running")

if __name__ == "__main__":
    if len(sys.argv) != 4:
        print(__doc__); sys.exit(2)
    directory = Path(sys.argv[1]).resolve()
    write_artifacts(directory, plan(directory, sys.argv[2], sys.argv[3]))

What does the planner refuse to approve?

RejectionWhat it prevents
REJECT_COLLISION_WITH:<name>Two source files renaming to the same target, including case-only differences on case-insensitive APFS volumes
REJECT_TARGET_EXISTSOverwriting an unrelated file already on disk at the new name
REJECT_PATH_SEPARATOR_OR_NULA substitution that would create a subdirectory or an invalid name
REJECT_EMPTY_OR_DOTA pattern that produces "", "." or ".."

The apply script is written only when every row is OK or SKIP_NO_MATCH. It uses mv -n, which refuses to overwrite an existing target even if the disk changes between review and apply. There is no automatic rollback: after mv has moved part of a batch, running the moves in reverse can collide with intermediate names. Keep the pre-rename copy and re-pull it on failure. The script has not been test-executed in this article, so run it on disposable sample data before real files.

What should I check before the real apply?

Work through this list against a copy of your files:

  • Pull a fresh working copy from your source of truth and leave the originals in place
  • Decide and record the target naming convention (case, separator, date format, padding, extension)
  • Run python3 rename_manifest.py ./copy '<regex>' '<replacement>' and open the generated TSV
  • Sort the TSV by NEW and scan for any STATUS other than OK or SKIP_NO_MATCH
  • Read 10 to 20 random OLD/NEW pairs end to end and confirm each new name makes sense to a person
  • Open rename-apply-*.sh, read every line and confirm the line count matches the OK row count
  • Apply to a 10-file subset first and verify the result
  • Run the apply script against the full working copy
  • Push the renamed files back to your storage or Git host and keep the pre-rename copy for one retention cycle

If the apply stops part-way, do not reverse the mv calls by hand. Re-pull the pre-rename copy and re-run the planner. Finder's Undo covers only renames made through Finder in the current session, not mv from Terminal.

How much Mac and disk does a batch rename need?

Batch renaming is light work, so the Intel Mac VM ($25 a month, $2 a day, 80GB SSD including the OS) is enough for most jobs. Size the disk for your working copy plus the original. If the renamed files later feed a build that needs Xcode 26.4 or later or arm64-only binaries, use the Apple Silicon Mac VM ($39 a month, $6 a day, 65GB SSD). Figment does not back up your Mac, so a source copy you control is the recovery path. See the plans on Figment Mac Hosting.

Related guides:

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan