Find Duplicate Files by Hash Across SD Cards and Drives
Find exact duplicate files by hash across SD cards and drives: Terminal and PowerShell commands, a safe review workflow, and the dedicated tools people name.
GuideUpdated 6 min read
On this page
You have a pile of SD cards, old drives and laptops, and you want "a tool that will hash every file and look for hash duplicates." That was the request from an IT admin clearing a late parent's media, about 500 GB across dozens of cards. People on r/sysadmin mostly pointed to fclones, then PowerShell grouping, then Czkawka. The first piece of advice was to back up everything, and that is where this guide starts.
Why hashing is the right way to find duplicates
A hash is a fingerprint of a file's content. Two files with the same SHA-256 hash have identical content, whatever their names, dates or folders say. That makes it far more reliable than comparing filenames, which fails on cards where different photos share a name like IMG_0001.JPG, and misses renamed copies.
The limits are worth knowing before you start:
- Exact hashing finds identical files only. A photo that was resized, edited or re-saved has a different hash and will not show up.
- A hash match does not tell you which copy to keep. That is your call.
- Hashing reads every byte, so a 500 GB run is limited mostly by drive speed.
Back up and gather everything in one folder
- Copy every card and drive to a drive with enough free space, one folder per source (
Card-01,Card-02,Old-Laptop). - Keep the original cards untouched until the clean-up is finished and you have checked the result.
- Run the hashing on the copies, not on the cards. Cards can be slow or disconnect mid-run, and you may need to read the data more than once.
One folder per source also tells you where each duplicate came from.
Find duplicates by hash on a Mac (Terminal)
find and shasum are built into macOS. Replace the path with your own folder, and keep the quotes if it contains spaces.
find "/Volumes/Backup/Estate" -type f -size +0 ! -name '.*' -exec shasum -a 256 {} + > ~/hashes.txtThis hashes every non-empty file under that folder with SHA-256 and writes one hash path line per file to hashes.txt in your home folder. ! -name '.*' skips hidden files such as .DS_Store and the ._ files macOS can leave on FAT and exFAT cards. -size +0 skips empty files, which would all match each other. An existing hashes.txt is overwritten.
If macOS asks whether Terminal may access files on a removable volume, allow it.
Next, list the hashes that appear more than once, then pull out the matching lines:
awk '{print $1}' ~/hashes.txt | sort | uniq -d > ~/dupe-hashes.txt
grep -F -f ~/dupe-hashes.txt ~/hashes.txt | sort > ~/duplicates.txtduplicates.txt now holds only files with identical content, sorted so each group sits together. If it is empty, there are no exact duplicates.
These commands only read your files and write three text files in your home folder. To undo them, delete hashes.txt, dupe-hashes.txt and duplicates.txt.
Find duplicates by hash on Windows (PowerShell)
This is the "PowerShell grouping" approach from the thread. To save time, it hashes only files that share a size with at least one other file, because a file with a unique size cannot have a duplicate.
Get-ChildItem -Path D:\Estate -Recurse -File |
Where-Object Length -gt 0 |
Group-Object Length |
Where-Object Count -gt 1 |
ForEach-Object { $_.Group } |
Get-FileHash -Algorithm SHA256 |
Group-Object Hash |
Where-Object Count -gt 1 |
ForEach-Object { $_.Group | Select-Object Hash, Path } |
Export-Csv D:\duplicates.csv -NoTypeInformationOpen duplicates.csv in a spreadsheet and sort by Hash. Write the CSV outside the folder you are scanning, as above. Add -Force to Get-ChildItem if you also want hidden files. The script only reads your files and writes the CSV; to undo it, delete duplicates.csv.
Dedicated duplicate finders people name
If you would rather not script this, these are the tools that came up. We have not checked any of them for platforms, speed, options or price, so we do not describe their features here. Read each project's own documentation before you pick one.
| Method | Best for | Trade-off |
|---|---|---|
Terminal (find + shasum) | Mac users, one-off clean-ups, nothing to install | Hashes every file; you review a text file by hand |
PowerShell (Get-FileHash + Group-Object) | Windows users; the size pre-filter skips unique sizes | You read a CSV, not a review-friendly list |
| fclones | Named most often in the thread | Not verified by us |
| Czkawka | Named as a dedicated finder | Not verified by us |
| rdfind, Alldup | Other finders people name | Not verified by us |
Whatever you choose, the safe workflow is the same: work on a backup, review the results, and move files aside before deleting.
Review before you delete
- Keep one copy per group, ideally the one in the best-organized folder.
- Move the others into a folder called
Duplicates-to-deleteinstead of deleting them. Check it, then delete it later. - Don't script deletion straight from the list until you have looked at a few groups by hand.
- Check paths and sizes in each group. Small files such as thumbnails or sidecar files can be genuinely identical without being clutter.
Checklist before you delete anything
- Every card and drive is copied to the backup, one folder per source.
- The hash run finished without errors on the copies.
- You opened a few duplicate groups and confirmed the files really match.
- Duplicates are moved to a holding folder, not deleted yet.
- The originals are kept until you have checked the final result.
If it doesn't work
hashes.txtis empty or tiny. Thefindpath is probably wrong or unquoted. Runls "/Volumes/Backup/Estate"with the same path to confirm it exists.- "Operation not permitted" or missing files. Terminal may not have access to the volume. Open System Settings, search for "Files & Folders", and allow Terminal to access removable volumes, then run the command again.
- The run stops partway. A card or drive probably disconnected. Hash the copies on your backup drive instead.
- It's taking a long time. Hashing reads every byte, so drive speed dominates. Avoid running it directly over slow cards.
- A known duplicate is missing. If the copies differ by even one byte, the hashes differ.
If a tool misbehaves, ask in that project's own issue tracker or documentation channel, and include the exact command, your OS version and the error text. A message you can adapt:
I'm hashing about 500 GB of files across several drives to find exact duplicates.
Command: <paste the exact command>
OS: <macOS or Windows version>
Problem: <what happened, e.g. the run stopped after N files>
Error text: <paste the exact message>
Already tried: running on a backup copy, confirming the path exists.Common questions
Is SHA-256 enough to find duplicates?
Yes, for finding identical files. It is the default in PowerShell's Get-FileHash, and shasum -a 256 uses it on a Mac.
Can I compare filenames instead?
You can, but names are unreliable across cards. Different cards can hold different photos with the same name, and renamed copies would be missed.
How do I check that one big copy matches its source?
Run shasum -a 256 /path/to/file on both and compare the results. The Hash Generator in Bytepliers does the same on its File tab, with an Expected checksum field that shows a match or mismatch. It hashes one file at a time and has no duplicate finder, so it does not replace the steps above. See how to check a SHA-256 checksum on a Mac.
Is there a Mac app for this?
For a Mac-focused look at duplicate finders, see Duplicate File Finder for Mac: Find and Remove Copies.