Perhaps every Mac owner starts looking for ways to free up space on their Mac after some time. Along with the way we use our computers, their storage gradually starts to take up more and more content. At the same time, a significant part of this content is useless and unused, and it often involves duplicate files of all kinds - photos, documents, or even files that we accidentally downloaded twice. What are the ways to find duplicate content on Mac and how to deal with it?
Dynamic folder in Finder
One way to find and possibly delete duplicate files on a Mac is to create a so-called dynamic folder in the native Finder. First, launch the Finder on your Mac, then head to the toolbar at the top of the screen. Here, click on File -> New Dynamic Folder. Click on the "+" in the upper right and enter the relevant parameters. In this way, you can search for photos, documents, files created on a specific day or files with a similar name. Before you decide to delete the supposed duplicates, first make sure that they are really identical files.
Terminal
If you are one of those users who prefers to work with the Terminal command line rather than the desktop, you may be more comfortable with this procedure. First, launch Terminal - you can do this via Finder -> Utilities -> Terminal, or you can press Cmd + Spacebar to activate Spotlight and type "Terminal" into its search box. You will then need to move to the appropriate folder, which in most cases is Downloads. Type cd Downloads in the command line and press Enter. Then enter the following command in the Terminal command line:
find ./ -type f -exec md5 {} \; | awk -F '=' '{print $2 "\t" $1}' | sort | tee duplicates.txt. Press Enter again. You will see a list of the contents of the Downloads folder, which will contain duplicate items.
The terminal example is a bit unlucky. On the one hand, you need to adjust the correct quotation marks for it to work, only that command will create a list of all files with their MD5 hash. Probably no one will want to look for duplicates in it.
A better solution, which will actually only list duplicates, is this command:
find . ! -empty -type f -exec md5sum {} + | sort | guniq -w32 -dD
The guniq command is used there, because the supplied uniq on MacOS does not have the full functionality and it is necessary to use the GNU version of the command. It can be easily installed using brew and the command is in the coreutils package. The installation is then:
brew install coreutils