Search code examples
macosduplicatesfindmdfind

MacOS - mdfind : How to find identical files from a content point of view with a given file?


I am looking for a way to find (one)/(multiple) files that (is)are identical to a given argument file. I would like to perform this with mdfind command which is really fast.

The command to apply would be for example like :

mdfind -options_same_content file_input.txt

I would like to do this research only on text files. I found on SO a lot of answers about this but it mostly based on Linux find/diff classical commands ...

If someone could indicate to me the flag -options_same_content to use with mdfind command, this would be fine.


Solution

  • In general, you can'd do this. The mdfind command queries the metadata database, and that doesn't have a record of what the contents of the objects are (such as a hashcode).

    What you could do is use a filter to find things that are the same size as the original file, then you can manually run an md5 or shasum on the content to see if they are the same.

    mdfind "kMDItemFSSize == 137536"                                 `