The duplicate photos, documents, audios and other types of duplicate files on your Mac can take up precious storage space. Getting rid of them frees up space and makes it easier to manage files. There are a few ways to do this. This article shows you how to find duplicate files on Mac in three ways, such as using Terminal, command line app built-in to macOS.
You can use Mac’s Terminal app to do a lot of cool things including searching for duplicate files. In Terminal, you can use MD5 or CRC algorithm to do the search, which identifies duplicates based only on content.
Note: Terminal requires command-line knowledge and is not for everyone. What’s more, it helps only with the identification of duplicate files on Mac. You need to manually delete the found duplicates one by one, which could take hours or longer.
If you have done a bit of search, you probably have found the syntax below and tried it.
find . -size 20 \! -type d -exec cksum {} \; | sort | tee /tmp/f.tmp | cut -f 1,2 -d ‘ ‘ | uniq -d | grep -hif – /tmp/f.tmp > duplicates.txt
However, it doesn’t work for many people including me. In my tests, it always returned “grep: –: No such file or directory” and failed to find any results.
Below is a working way to use Terminal to detect the duplicate files on your MacBook Air, MacBook Pro or iMac etc.
1. Open Terminal. Go to Finder > Applications folder > Utilities folder and click Terminal. Alternatively, search Terminal in Spotlight.
2. To find duplicates in a folder, say, Desktop, type “cd Desktop” and hit Return.
If you want to search your entire Home folder, ignore this step.
3. Enter the following syntax and then hit Return.
grep -hif <(find . \! -type d -exec md5 -r {} \; | sort | tee /tmp/f.tmp | cut -f 1,2 -d ' ' | uniq -d) /tmp/f.tmp > duplicates.txt
4. When the process is done, open the file “duplicates.txt” which displays the list of duplicate files Terminal has found on your Mac.
Now you can remove duplicate files one by one according to the list. In the list, if two or more files show the same hash (displayed on the left), then they are duplicates. And you can keep one file and delete the rest. A file’s path (displayed on the right) can help locate the file in Finder for you to delete.
Here are some tips that you may find helpful.
Tip 1
If you want to use CRC algorithm instead of MD5, run the following syntax in Terminal instead.
grep -hif <(find . \! -type d -exec cksum {} \; | sort | tee /tmp/f.tmp | cut -f 1,2 -d ‘ ‘ | uniq -d) /tmp/f.tmp > duplicates.txt
Tip 2
If you want to use Terminal to find a specific type of duplicate files, say, duplicate JPG photos, an extra command is needed.
grep -hif <(find . \! -type d -iname '*.jpg' -exec md5 -r {} \; | sort | tee /tmp/f.tmp | cut -f 1,2 -d ' ' | uniq -d) /tmp/f.tmp > duplicates.txt
Tip 3
Once Terminal finishes scanning a Mac folder for duplicate files, it will generate a TXT file, which provides you with a list of the found duplicate files via displaying their paths. Entering a file’s path in Finder’s Go to Folder will open the file in Finder. If it doesn’t, then the path is incomplete. In my test, I needed to make it complete by manually adding “~/Desktop”.
Just like Terminal, Finder is also an app that is included with macOS. It’s a file manager with a great search feature. Although it doesn’t provide an option to identify duplicate files, it enables you to easily narrow your search results, which can make it much easier to manually find duplicate files.
With this method, it’s recommended to handle only a type of duplicates (such as duplicate images) at a time. Also, it’s recommended to search a folder (such as Desktop or Downloads) instead of your entire Mac for duplicates.
1. In Finder, open the folder in which you want to find duplicate files.
2. Enter “image” in the search field. Choose Image in the Kinds list that appears.
3. Change the search location from This Mac to the folder in question. Now the Finder window will display all the image files in this folder, including those in the subfolder.
4. This step is optional. You can click the Add button to add criteria to this search. For example, exclude images with certain names.
5. Display images by name (or size).
6. Now you can easily identify duplicate files by comparing file content and file information. The Preview pane on the right enables you to view files and file information.
When you find a duplicate file that you don’t want to keep, you can directly delete the file in Finder by control-clicking it and choosing Move to Trash.
After finishing handling one type of duplicate files, you can start finding another type.
You can find duplicate files on Mac with Terminal for free using certain syntax or with Finder. If you want to remove the unwanted duplicates, you need to do it manually one by one, which can be time-consuming and tedious. Luckily, you can use Cisdem Duplicate Finder, which is the best Mac duplicate file finder software, to get the job done effortlessly and effectively.
Cisdem Duplicate Finder main feature:
1. Download and install the software on your Mac.
2. Click the plus icon to add a folder or drive. Click Scan.
To find duplicates files in and across multiple locations, add all the locations.
3. Once it’s done, you can find all the found duplicates under the All tab. You can also view them by file type.
4. This duplicate file finder and remover already automatically selects duplicate files for deletion.
If not satisfied with auto-selection, highlight all items under All tab with Command-A and choose a selection rule.
5. Now click Delete to remove the unwanted duplicate files from your Mac.
A couple of extra steps are needed when the software handles Photos or iTunes.
Does Mac have a duplicate file finder?
The answers are: no and yes. macOS doesn’t come with a direct app or feature to directly scan for duplicate files in folders or on your entire Mac. But Mac’s Music app (previously iTunes) provides a feature to find duplicate music files in your music library and Mac’s Photos app (on macOS Ventura only) provides a feature to find duplicate photos in your photos library.
When it comes to the third-party duplicate file finder for Mac, there are a number of choices.
Why is my Mac duplicating files?
Some duplicate files may be created by the operating system itself or a certain app. It could be caused by a glitch, but in most cases, the operating system or an app does this to make itself work properly. Some duplicate files on Mac are created by you, the user, accidentally or intentionally. For example, you may download or import the same files more than once.
You can find duplicate files on Mac in several ways, such as using Terminal, Finder or dedicated software. If you are familiar or comfortable with command line, you can use Terminal. You can also use manually identify and eliminate duplicate files via Finder. With dedicated software, the identification and removal of duplicate files becomes extremely easy and quick.
Rosa has worked in Mac software industry for more than eight years. She believes that the purpose of software is to make life better and work more productively. In addition to writing, Rosa is also an avid runner.
Birgit Walenta
I had lots of useless duplicate files on my mac, and i followed these steps and now they are all gone!!! thank u!