everyday mac tools

Find duplicate files on a Mac without deleting the wrong copy

· 6 min read

Finding duplicate files on a Mac is not difficult. Deciding which copy to keep is where people lose work. The rule that avoids nearly every bad outcome: match files by their contents rather than their names, look at where each copy lives before you touch it, and move candidates to the Trash instead of deleting them.

There is also a wrinkle specific to modern Macs. On an APFS disk, two identical files do not always occupy twice the space, so deleting one of them can free nothing at all.

What actually counts as a duplicate

Three different things get called duplicates and they need different treatment.

Byte-identical copies. The same file in two places. These are the only ones a checksum can prove, and the only ones you can delete with confidence.

Same name, different contents. report.pdf in Downloads and report.pdf in Documents may be two drafts a week apart. Matching by name is how people delete the newer one.

Near duplicates. The same photo exported at two sizes, a video and its compressed version, a document and its PDF. No tool can tell you which of these you want, because that is a judgment about your work.

Anything that promises to sort all three out automatically is guessing at the third.

The copies you must not touch

Before running anything, know the places where repeated files are structural rather than accidental. Removing them breaks software.

  • Inside app bundles. Frameworks bundled by several apps look like duplicates. They are not.
  • Inside your Photos library. The .photoslibrary package holds originals, renders and thumbnails of the same image by design. Never reach inside it in Finder.
  • Developer folders. node_modules, .git, virtual environments, Xcode’s DerivedData and package caches are full of legitimately repeated files.
  • Backup disks and Time Machine volumes. A backup is meant to be a duplicate of your disk.
  • System folders. Anything under /System or /Library that you did not put there.

The practical rule: scan the folders you personally fill up. Documents, Downloads, Desktop, a media folder. Not your whole home folder, and definitely not the whole disk.

The APFS wrinkle worth knowing about

macOS uses APFS, which supports cloning. When you use File, then Duplicate in Finder, macOS does not copy the data. It creates a second name pointing at the same blocks, and writes new data only if one of them changes. Two 4 GB video files can share one 4 GB of disk.

Two consequences follow. Deleting one of a cloned pair may free almost nothing, so the total a duplicate scan promises can be optimistic. And sizes reported by different tools will disagree, because some count what a file appears to be and some count what it costs. The Mac says storage is full but the folders do not add up covers the other reasons.

None of this makes deduplication pointless. It means you should judge the result by the free space you actually recover, not by the total a scan predicted.

Start with Photos, which has its own tool

If your duplicates are pictures, macOS already solves this and does it better than a file-level scan can. Ventura and later include a Duplicates album in the Photos sidebar. It finds images and videos that are the same or nearly the same, and Merge keeps the highest quality version along with the combined metadata, keywords and album memberships.

Use that rather than any approach that treats photos as files. A file-level tool sees two JPEGs; Photos sees one moment shot twice, knows which version is edited and which albums each is in, and keeps the right one. The Photos library is taking up space covers the rest of what a photo library holds. The album takes a while to populate on a large library, and does not appear at all if nothing was found.

Finding byte-identical files yourself

For everything else, neither Finder nor Spotlight can do this. Terminal can, using checksums, and it is worth doing this way once because you see the evidence rather than a verdict.

Point it at one folder, not your whole home directory.

  1. Hash every file over 1 MB in the folder and sort the result:
find ~/Downloads -type f -size +1M -exec shasum -a 256 {} + | sort > ~/Desktop/hashes.txt
  1. Pull out the hashes that appear more than once:
cut -c1-64 ~/Desktop/hashes.txt | uniq -d > ~/Desktop/dupes.txt
  1. List every file belonging to those hashes:
grep -F -f ~/Desktop/dupes.txt ~/Desktop/hashes.txt

The output groups identical files together, one per line, with the full path. Files whose contents differ by a single byte will not appear, which is the point: a match here is a genuine match.

The size filter matters. Without it you spend a long time hashing thousands of files whose duplicates amount to nothing. Raise it to +50M if you only care about copies costing you real space. To scan an external drive, use its path under /Volumes.

Where duplicates actually pile up

Most Macs have the same four sources, and going straight to them is quicker than scanning everything.

Downloads. The classic pattern is invoice.pdf, invoice (1).pdf, invoice (2).pdf, from downloading the same attachment three times. Sorting Downloads by name puts these next to each other, which is often faster than any scan. Tidy the Downloads folder without losing anything goes through the whole folder.

Attachments saved twice. Once to the Desktop to look at, once to a project folder to keep.

Imports. A camera card copied to the Mac, imported into an app, and left on the Mac as well.

Old migrations. A folder from a previous Mac sitting alongside the current version of the same material. The largest and the most dangerous, because the two trees are usually similar rather than identical.

Deciding which copy to keep

When a group of identical files comes back, keep the one in the location that other things point at. In order of preference: the copy inside the folder structure you actually work in; the copy inside your backup scope, if you back up selectively; then the copy with the oldest creation date, which is usually the original rather than the re-download. Delete from Downloads, from the Desktop, and from anywhere ending in (1).

Then do it safely. Move the copies you do not want to a folder called duplicates-to-delete on the Desktop, or to the Trash. Use the Mac for a week. Nothing that was linked, referenced or opened by another app will survive a week without complaining. Then empty it.

If you would rather have this presented as a list you approve than assembled in Terminal, Crumb includes a Duplicates tool that shows what it found and what it proposes to remove before anything happens, and lets reclaimable removals be reviewed and undone afterwards. It is part of the paid unlock. It cannot recover a file deleted somewhere else, and neither can macOS, which is the whole reason for the week in the Trash.

Questions

Can Spotlight or Finder find duplicates? Not by content. A Smart Folder (File, then New Smart Folder in Finder) can list every file over a certain size or of a certain kind, which is a useful way to see candidates, but it cannot tell you two files are identical. That takes a checksum.

Are files in iCloud Drive counted twice? No. A file in iCloud Drive is one file that may or may not be downloaded to this Mac. With Optimize Mac Storage on, the copy on disk can be a placeholder taking almost no space, which also means a duplicate scan may not see its contents at all. Check that a file is downloaded before comparing it.

Is it safe to let a tool pick which copy to keep? Only if you read the list first. Automatic rules such as keep the shortest path or keep the newest are reasonable defaults and wrong often enough to matter. The review is the part that protects you, so treat any tool that skips it as unfinished.