- Posted on
- • Apps
How to Batch Rename Files on Windows, macOS, and Linux
- Author
-
-
- User
- FilesRename
- Posts by this author
- Posts by this author
-

How to Batch Rename Files on Windows, macOS, and Linux
Introduction
Renaming files one by one is a productivity killer. If you deal with photos, invoices, reports, or exported assets, you’ll eventually need to batch rename files for consistency and searchability. The good news: every major desktop platform—Windows, macOS, and Linux—offers fast and safe ways to rename multiple files at once using built-in tools or lightweight utilities. In this tutorial, you’ll learn step-by-step workflows with previews, regex essentials, metadata tips (like EXIF for photos), and automation tricks that scale from dozens to thousands of files.
Why Batch Renaming Matters
A strong naming convention turns chaos into clarity. It improves search, reduces duplicate work, and makes collaboration painless. For example, compare “IMG_0001.jpg” to “2025-10-04_wedding-ceremony_001.jpg”. The second one is sortable, human-readable, and machine-friendly. Before we dive into tools, define a simple pattern:
- Prefix: project or context (clientA, wedding, q4-report).
- Date: ISO format YYYY-MM-DD for lexicographical sort.
- Descriptor: short label (raw, logo, ceremony).
- Sequence: zero-padded numbers (001, 002...).
Keep names lowercase, use hyphens instead of spaces, avoid special characters, and keep extensions intact. We’ll apply these ideas across platforms so your bulk rename workflow becomes predictable and safe.
Windows: Fast Renames with Explorer, PowerRename, and PowerShell
Windows offers three great approaches: a quick built-in option, a powerful GUI tool from Microsoft, and scripting for power users.
1) Quick renaming in File Explorer
For simple sequences, select all files in a folder, press F2, type a base name (e.g., projectA_), and hit Enter. Windows applies a sequence like projectA_ (1).ext, projectA_ (2).ext, etc. It’s instant, but limited—no prefixes by date or complex replacements.
2) PowerRename (Microsoft PowerToys)
For advanced find/replace (including regex) with preview, install PowerToys PowerRename 🔗. After installing, select files in Explorer, right-click, choose PowerRename. You’ll see:
- Search and Replace fields with checkboxes for Use Regular Expressions.
- Options for Match All Occurrences, Case Sensitive, Exclude File Names/Extensions.
- A live preview pane showing old vs. new names before applying.
Examples:
- Add a date prefix: Search:
^
Replace:2025-10-04_
(anchors at start). - Normalize spaces to hyphens: Search:
\s+
Replace:-
. - Lowercase extensions only: Enable “Exclude file names”, Search:
[A-Z]+$
Replace:\L$0
(use to lower if offered).
Why PowerRename? It’s safe (preview first), powerful (regex), and fast for batches in the hundreds or thousands.
3) PowerShell for scripted control
Open Windows Terminal or PowerShell in the target folder (Shift + right-click → “Open PowerShell window here”). A quick pattern:
- Replace spaces with hyphens:
Get-ChildItem -File | Rename-Item -NewName { $_.Name -replace '\s+','-' }
- Add date prefix:
$d='2025-10-04_'; Get-ChildItem -File | Rename-Item -NewName { $d + $_.Name }
- Sequential numbering (zero-padded):
$i=1; Get-ChildItem -File | Sort-Object Name | ForEach-Object { $n = '{0:D3}' -f $i; Rename-Item $_ -NewName ("wedding-ceremony_" + $n + $_.Extension); $i++ }
Tip: Always test with a subset first. You can simulate (print only) by outputting the new names instead of calling Rename-Item
.
macOS: Finder’s Built-In Batch Rename, Terminal, and Shortcuts
On macOS, you can use Finder’s rename pane for most tasks, Terminal for power work, and Shortcuts/Automator to build reusable flows.
1) Finder’s batch rename
Select files in Finder, right-click → Rename X Items.... You’ll see three modes:
- Replace Text: swap tokens (e.g., replace spaces with hyphens).
- Add Text: add a prefix/suffix (e.g., 2025-10-04_).
- Format: build a name with a base + index (choose where numbering appears, and pad digits).
It’s safe (preview at the top) and handles most daily needs. Para referência oficial, veja Rename files and folders on Mac 🔗.
2) Terminal with bash/zsh
Open Terminal in your folder. Useful patterns:
- Replace spaces with hyphens:
for f in *\ *; do mv "$f" "${f// /-}"; done
- Lowercase all extensions:
for f in *.*; do ext="${f##*.}"; base="${f%.*}"; mv "$f" "${base}.${ext,,}"; done
- Sequential numbering:
n=1; for f in *.jpg; do printf -v p "%03d" "$n"; mv "$f" "event-ceremony_${p}.jpg"; ((n++)); done
For regex-like mass changes, consider perl
or rename
(available via Homebrew as rename
/ mmv
). Keep backups and test with a small set first.
3) Shortcuts (or Automator) to build a one-click workflow
Use the Shortcuts app to create a “Quick Action” that:
- Receives files as input from Finder.
- Asks for a prefix/date, then runs a rename action.
- Optionally writes a log file with before/after names.
This is perfect for repeating jobs—like weekly camera dumps—without retyping commands.
Linux: rename/mmv, Bash Loops, and Power Utilities
Linux distributions provide robust CLI tools for bulk operations. Two classics are rename
(Perl-based) and mmv
.
1) The rename
utility (Perl)
Install via your package manager (e.g., Debian/Ubuntu: sudo apt install rename
). Syntax uses Perl regex:
- Spaces to hyphens:
rename 's/\s+/-/g' * *
- Add a prefix:
rename 's/^/2025-10-04_/' *
- Lowercase extensions:
rename 's/\.(\w+)$/.\L$1/' *
Do a dry run by echoing the intent first: for f in *; do echo mv "$f" "$(echo "$f" | sed -E 's/[[:space:]]+/-/g')"; done
.
2) mmv
for wildcard-based mass moves
mmv
maps many files to many files using patterns:
- Add “event-” to the beginning:
mmv '*.*' 'event-#1.#2'
- Replace spaces: often simpler to pre-clean with
rename
and then applymmv
patterns.
If you prefer pure Bash, the for
loop with parameter expansion is enough for most workflows.
Using Regex Safely (Windows, macOS, Linux)
Regex (regular expressions) gives you surgical precision, but it’s easy to make mistakes. Keep these patterns handy:
- Start of name:
^
- End of name:
$
- Digits:
\d+
(one or more digits) - Whitespace:
\s+
- Capture group:
(...)
, reference as\1
(or$1
depending on the tool)
Examples:
- Swap “Report_2025_Q4” to “2025-Q4_Report”:
Search:^Report_(\d{4})_(Q\d)$
→ Replace:\1-\2_Report
- Normalize multiple underscores to one:
Search:_+
→ Replace:_
- Keep extension intact by excluding it from the match, or by capturing
(\.[^.]+)$
and reusing as\1
.
Always preview. In GUI tools (PowerRename, Finder) check the before/after list. In CLI, print the intended new names before running mv
or Rename-Item
.
Working with Metadata: Photos, Audio, and Documents
Sometimes, the correct filename isn’t inside the current name—it’s in the file’s metadata. Photographers often build names from EXIF timestamps; podcasters use audio tags; analysts need document properties. Enter ExifTool, a cross-platform Swiss army knife for metadata.
Download from the official site: ExifTool 🔗. Examples:
- Rename JPEGs by create date:
exiftool '-filename<${CreateDate}_\$filename' -d %Y-%m-%d_%H-%M-%S *.jpg
- Rename to YYYY-MM-DD_event_### (sequence by directory order):
exiftool '-filename<${CreateDate}_event_${FileSequence}.%e' -d %Y-%m-%d *_raw.jpg
- Write a dry-run report: use
-p
to print planned names or run in a copy of the folder first.
For audio, tools like MusicBrainz Picard 🔗 can write tags; then you can rename files based on artist/album/track patterns. For PDFs and Office docs, consider scripts that extract properties and format filenames consistently.
Edge Cases and How to Handle Them
Even pros get tripped up by edge cases. Watch out for:
- Mixed extensions in the same batch (handle per type: *.jpg, *.png, etc.).
- Hidden files (like ._DS_Store or .thumbnails): exclude them to avoid errors.
- Name collisions (two files would get the same output name): use zero-padded sequences.
- Very long paths (Windows): work closer to the drive root or enable long path support.
- Unicode characters: prefer UTF-8 friendly tools; normalize to ASCII if the target system is picky.
If something fails mid-rename, your best friend is a simple log (before/after mapping). Many GUI tools show this by default; on CLI, generate one with a loop that prints both names to a .csv before executing.
Automation: Turn Repetitive Tasks into One-Click Flows
If you rename similar batches weekly, automate it:
- Windows: Save PowerShell scripts (.ps1) and run them via a right-click context menu or Task Scheduler.
- macOS: Use Shortcuts to build a “Quick Action” that asks for prefix/date and renames with one click.
- Linux: Create shell scripts and bind them to a file manager action (e.g., Nautilus scripts) or a desktop launcher.
Pro tip: Parameterize dates and descriptors so you reuse the same script across clients and projects without editing code each time.
Safety First: Previews, Backups, and Reversible Flows
Batch operations are powerful—and unforgiving. Protect yourself with a safety checklist:
- Work on copies if the files are critical.
- Preview in GUI tools and dry run in CLI (print intended names first).
- Versioned backups (e.g., sync to a cloud drive) before big renames.
- Log mapping (old → new) to recover from mistakes.
- Keep extensions intact unless you intentionally convert.
Troubleshooting: When Things Don’t Go as Planned
If a command errors out, simplify your batch:
- Run on a smaller subset first.
- Escape special characters (spaces, parentheses) with quotes.
- Check permissions (read-only files won’t rename).
- On Windows, verify that no other app is locking the file (e.g., a previewer).
If file names “disappear,” you may have renamed them with leading dots (becoming hidden). Turn on “show hidden files” or remove the dot.
Putting It All Together: A Cross-Platform Template
Here’s a simple plan you can reuse on any OS to bulk rename safely:
- Copy the files to a working folder (or ensure a backup exists).
- Plan the naming convention: date_context_descriptor_###.ext.
- Preview:
- Windows: PowerRename preview.
- macOS: Finder rename preview.
- Linux: echo the intended rename mapping.
- Execute the rename.
- Verify sort order, uniqueness, and extension correctness.
- Log old/new names to a CSV for reference.
Helpful Links and Tools
- PowerToys PowerRename (Microsoft) 🔗
- Rename files and folders on Mac (Apple) 🔗
- ExifTool (metadata renaming) 🔗
- MusicBrainz Picard (audio tags) 🔗
Conclusion
Mastering how to batch rename files is a small skill with huge impact. Start with previews in Explorer or Finder for quick wins; move to PowerRename, Terminal, or rename when you need patterns, regex, or scale. Add metadata tools like ExifTool to unlock perfect filenames from camera data. With a clear naming convention and a safe, repeatable workflow, you’ll go from messy folders to clean, searchable archives in minutes.
What’s your current naming convention? Prefers hyphens or underscores? Any tricky edge cases you want help with—like mixed extensions or multilingual filenames? Deixe nos comentários e vamos organizar isso juntos!
FAQ
- Can I undo a batch rename? GUI tools often don’t provide a one-click undo. Keep backups or a log (old → new) so you can revert manually if needed.
- Is regex required? No. Regex helps with complex cases, but Finder/PowerRename handle most common patterns without it.
- What about huge batches (10k+ files)? Use CLI (PowerShell, Bash) and run in chunks. Avoid network drives during the rename to reduce lock issues.
- How do I keep file extensions intact? Exclude extensions in GUI settings or capture and reinsert them in your replace pattern.
- Can I rename by photo date automatically? Yes, use ExifTool 🔗 to pull timestamps and format filenames precisely.