Find Duplicate Files using Mac Terminal Command


There are tons of free and paid apps available for Mac to identify duplicate files and clean them, but do you know you can identify and delete duplicate files easily using the Mac Terminal, all you need is a package called fdupes

You can download this package using brew

brew install fdupes

GitHub: https://github.com/adrianlopezroche/fdupes

⛏️ Installing Brew on Mac

Example: Find all duplicates in the Downloads folder
% fdupes -r -S Downloads

2513563 bytes each:
Downloads/mysql-connector-java-8.0.30/mysql-connector-java-8.0.30.jar
Downloads/mysql-connector-java-8.0.30.jar

1113 bytes each:                          
Downloads/2020101_Image.png
Downloads/temp.png


24958 bytes each:                          
Downloads/college-trip.mp4
Downloads/college-trip-copy.mp4

As you can see, I was able to get duplicate files - Images, Software, and Videos with the size they occupy!

Few useful options
-r --recurse     :for every directory given follow subdirectories encountered within
-s --symlinks    :follow symlinks
-G --minsize=SIZE      :consider only files greater than or equal to SIZE bytes
-L --maxsize=SIZE      :consider only files less than or equal to SIZE bytes
-A --nohidden        :exclude hidden files from consideration
-S --size          :show size of duplicate files

Deleting the files

Use -d as an option with the command, Note: You should be extra cautious while using this command to delete file,

% fdupes -d -r /Downloads/myFiles

You will get an interactive screen for duplicate files asking which one to keep.

Find and delete files using Mac Terminal Command

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap