Skip to content

Instantly share code, notes, and snippets.

@Alexwi1son
Forked from mblarsen/gist:e24c73aa8004bb0bccfc
Last active September 15, 2025 03:54
Show Gist options
  • Save Alexwi1son/6e4c5125ed48e917f0487a6b07fcf834 to your computer and use it in GitHub Desktop.
Save Alexwi1son/6e4c5125ed48e917f0487a6b07fcf834 to your computer and use it in GitHub Desktop.
Removing duplicate files

Method 1: Removes duplicates from a directory based on checksum

Find duplicates and write to duplicates-report.txt

find . -type f -exec cksum {} ; | sort | tee /tmp/f.tmp | cut -f 1,2 -d ' ' | uniq -d | grep -hif /dev/stdin /tmp/f.tmp > duplicates-report.txt

Delete duplicates based on duplicates-report.txt

sort -k1,1 duplicates-report.txt --stable | gawk -F' ' '{if ( $1==old ) { print $3 }; old=$1; }' > duplicates-only.txt | xargs rm

Method 2: Removes duplicates fastly and easily with AnyDupeCleaner App

AnyDupeCleaner is a very reliable and efficient tool for finding and deleting duplicate files on Windows and Mac. And the process is simple and straightforward.

Step 1: Download & install

Download and install the app directly from the following link:

 

anydupeclean mac home

Step 2: Add folders to scan

Launch the app, then hit the “+” at the bottom to add folders. I usually scan Downloads, Documents, and my Pictures folder.

anydupecleaner mac add folder

Step 3: Set your scan options

Want to scan just photos? Or ignore system files? You can tweak filters — file type, size range, date, and more. (I unchecked system folders to speed things up.)

anydupeclean mac scan options

Step 4: Start scanning

Hit "Scan" and let it do its thing. For me, it took under 2 minutes to go through 20,000+ files.

anydupecleaner mac scanning

Step 5: Review duplicates

You'll get a nice list grouped by file name, size, or even exact content. You can preview photos, videos, or documents before deciding.

One thing I particularly like is that AnyDupeCleaner automatically determines the modification date of the file, and by default keeps the original file with the earliest date, and selects the newer duplicates for deletion.

In other words, if you have three identical photos, the system will keep the earliest one (usually the one you saved originally) instead of accidentally deleting the original one. This way, you don't have to worry about the important original file being accidentally deleted, which is very suitable for people who have multiple versions of photos or work documents.

anydupecleaner mac review

Step 6: Select & delete

Click the Select All button to keep one copy and delete the rest. Then just hit "Delete", and boom — space saved. On my computer, A total of 4278 photos were deleted successfully!

anydupeclean mac remove duplicates

Download the trail version here, really worth a try!

 My thoughts

After using AnyDupeCleaner, I cleared almost 9 GB of duplicates I didn't even know existed. The UI is clean (feels native to macOS), and I never had to read a manual or Google anything. For someone who hates over-complicated tools, that's a win.

Final tip

Run this once every couple of months — especially if you're a digital hoarder like me. Your SSD (and sanity) will thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment