Guides

How to batch rename files safely

· 6 min read

Batch renaming is easy to do and easy to do irreversibly. The operation itself is trivial; the risk is that the original names carried information nobody wrote down anywhere else.

Pad your numbers

The most common mistake. Naming files photo-1 through photo-10 produces a sort order of 1, 10, 2, 3, because almost everything sorts names as text rather than as numbers. The fix is to pad to a fixed width: photo-001, photo-002, photo-010.

Pad to the width of the largest number you expect, not the largest you currently have. Three digits covers 999 files and costs nothing.

Put the date first, in the right order

If names start with a date, write it as year then month then day. That is the only ordering where sorting alphabetically also sorts chronologically. Day-first or month-first names sort into an order that means nothing.

PatternSorts correctly?
2026-09-22-reportYes
22-09-2026-reportNo, groups by day of month
Sept-22-2026-reportNo, alphabetical by month name
report-1 to report-10No, 10 sorts before 2

Characters to avoid

The two ways to lose data

The first is a collision. If two different files end up with the same new name, one can overwrite the other. Any sensible tool refuses or disambiguates, but it is worth confirming which it does before running a batch of several hundred.

The second is discarding meaning. Original camera names encode capture order. Scanner output often encodes the page number. Once those are replaced by a clean sequence, the original ordering is only recoverable from file timestamps, which some transfers do not preserve.

Preview the full list of old and new names before committing, and keep the mapping. A batch rename is not reversible by itself; only a record of what changed makes it reversible.

Patterns worth having

The renamer here shows the resulting names before anything is applied and runs entirely in the browser, so the files stay on your machine.

Frequently asked questions

Why do my files sort 1, 10, 2?

Names are sorted as text, not as numbers. Pad the numbers to a fixed width, such as 001, and the text order matches the numeric order.

Can I undo a batch rename?

Not by itself. Keep the list of old and new names before you apply it; that mapping is the only reliable way back.

Are spaces in filenames a problem?

Not for the file system, but they need quoting in scripts and encoding in URLs. Hyphens avoid both without losing readability.