Filename collisions, and how not to lose a file
Two files cannot share a name in the same folder, and the tools that move and rename files handle that very differently — some ask, some refuse, and some silently overwrite. Here is where collisions come from and how to avoid losing work to one.
A folder cannot contain two files with the same name. When an operation would create a second one, something has to give: the operation stops, one file gets a different name, or one file replaces the other.
That last outcome is how people lose work without noticing — and it depends entirely on which tool made the change.
How different tools behave
Finder, renaming one file. Type a name that already exists and Finder refuses: it tells you the name is already taken. Nothing is lost.
Finder, copying or moving. Drag a file into a folder that already has one with the same name and Finder asks: Keep Both, Stop or Replace. Keep Both adds a number to the new file's name. Replace deletes the existing file. Read the dialog — it is easy to click Replace out of habit.
Terminal: mv and cp. By default, they overwrite silently. mv draft.txt report.txt replaces any existing report.txt without a question. The old file is not in the Trash; it is gone. Add -i to be asked first, or -n to never overwrite:
mv -n draft.txt report.txt
Scripts and automation. A script that renames files in a loop inherits whatever its commands do — usually the silent overwrite. This is how a batch rename can reduce four hundred files to two hundred.
Sync services. When two devices change the same file, most cloud services keep both, adding a "conflicted copy" or device name to one. Nothing is lost, but you now have two files to reconcile.
Where collisions come from
Removing distinguishing text. Delete _final from every name and Report.pdf and Report_final.pdf become the same name.
Dates without times. Renaming photographs to their date alone — 2026-10-04.jpg — collides on the second photograph of the day. Include the time, and a counter for burst shots.
Case differences. macOS treats Photo.jpg and photo.jpg as the same name by default. A rule that lowercases every name will collide wherever two files differed only in capitals — which they can if they came from a Linux server or a camera card.
Look-alike characters. An accented letter can be stored in two different ways — as one character, or as a letter plus a combining accent. macOS treats both forms as the same name, so two files that looked different elsewhere can collide when copied onto a Mac.
Swaps and cycles. Renaming A to B and B to A in one batch cannot be done directly: the first step collides with the second file. It needs a temporary name in between. Naive tools either fail halfway or overwrite.
Truncation. Shortening long names to a fixed length makes names that differed only at the end identical.
How to avoid losing a file
Preview the whole result. Before any batch rename, look at every proposed name, sorted, and look for duplicates.
Include something unique. A counter, a time to the second, or the original number from the camera. Unique inputs make unique names.
Never let a tool overwrite by default. In Terminal, -n or -i. In apps, prefer those that stop or skip rather than replace.
Work on a copy the first time. For a new rule on important files, run it on a duplicate folder first.
Have a backup. Time Machine or another backup is the only complete protection. A file overwritten by mv is not in the Trash, but it is in last hour's backup.
If it already happened
- Finder Replace: do not count on the replaced file being in the Trash. Look there, but go to your backup next.
- Terminal overwrite: check Time Machine — enter it from the folder in Finder and go back to before the change.
- Cloud folders: most services keep version history or recently deleted files for a period. Check the service's website.
- Recent documents: some apps keep their own version history. File → Revert To → Browse All Versions in many Mac apps shows earlier saved versions.
Where RenameDeck fits
RenameDeck is a batch renamer for Mac designed so that collisions are found before they matter.
The complete list of proposed names is shown before anything changes, searchable, with collisions and invalid names flagged. RenameDeck never overwrites an existing file. Its renames are journaled transactions that handle swaps, cycles and case-only changes — the cases that trip up simple tools — and survive interruption. A persistent, identity-protected history offers undo only while the destination is still the file that was renamed.
Counters, zero padding, dates to the second and capture-time metadata give each file something unique to be named after. RenameDeck is sandboxed with no network entitlement, account, analytics or tracking, and requires macOS 14 or later.