MacOS – Find files with the same content in one folder (and all its sub-folders)

filemacos

Say I have a folder named container and there are many files/sub-folders in it. I would like to find all the files with the same content (they can have different names but the content should be the same).

Is there any way I can do this on Mac?

Best Answer

If you're comfortable using the Terminal, you can try rdfind which purpose is precisely to find duplicate files.

You'll need to install it with Homebrew first: brew install rdfind

Then, let's say you want to run a dry test on your ~/Download folder:

rdfind -n true -outputname result.log ~/Downloads/
  • -n true is for dry mode: no files will be affected
  • -outputname result.log will output the scanning into that file
  • ~/Downloads/ is the argument of the root folder you want to scan (you can pass more than one folder)

Running that command will look something like that:

$ rdfind -n true -outputname result.log ~/Downloads/
(DRYRUN MODE) Now scanning "/Users/ym/Downloads", found 20132 files.
(DRYRUN MODE) Now have 20132 files in total.
(DRYRUN MODE) Removed 0 files due to nonunique device and inode.
(DRYRUN MODE) Now removing files with zero size from list...removed 75 files
(DRYRUN MODE) Total size is 59782752628 bytes or 56 GiB
(DRYRUN MODE) Now sorting on size:removed 3795 files due to unique sizes from list.16262 files left.
(DRYRUN MODE) Now eliminating candidates based on first bytes:removed 579 files from list.15683 files left.
(DRYRUN MODE) Now eliminating candidates based on last bytes:removed 134 files from list.15549 files left.
(DRYRUN MODE) Now eliminating candidates based on md5 checksum:removed 94 files from list.15455 files left.
(DRYRUN MODE) It seems like you have 15455 files that are not unique
(DRYRUN MODE) Totally, 324 MiB can be reduced.
(DRYRUN MODE) Now making results file result.log

Or, you can use an application with a graphical interface like dupeguru:

choose folder to scan

scan result