3

I'm in a weird situation. I need to find a file based on its contents, not the name because the name is not unique...

For example, I have a file named "cat.jpg". It is a picture of a cat. I happen to have 5 million copies of that in 5 million different folders, so, while the folder names are different, the file names are the same:

cat1/cat.jpg
cat2/cat.jpg
cat3/cat.jpg
etc...

However, one of those cat.jpgs is actually a picture of a dog (and the file is still named "cat.jpg")

How can I find the one that is a dog assuming I have an exact copy of it available. I can't do filename search because then I'll just get 5 million results of "cat.jpg"

2
  • While the fc based answer is perfectly valid, if you need a GUI then any good duplicate file finder should do the trick.
    – Karan
    Mar 26, 2013 at 9:45
  • Is there any text in the cat.jpg file that can be used to exclude it? Open it up in something like Hxd and look for a bit of text that you could possibly use.
    – snowdude
    Mar 26, 2013 at 10:14

3 Answers 3

2

Here's an example using fc.exe with the binary compare flag:

for /R "C:\Some Path" %f in (*.jpg) do @(FC /B "C:\Some Other Path Maybe\dog.jpg" "%f" | FIND "FC: no differences encountered.") && echo %f

This will recursively go through the files and folders in C:\Some Path assigning the JPEGs to %f. FC will pipe the output of the comparison with dog.jpg and %f to the string comparison utility, FIND.

If the files match the output from FC will be FC: no differences encountered.

The && means that echo %f will fire if that string is found by FIND.

So if there is a match you should see something like

FC: no differences encountered.
C:\Some Path\cat5000000\cat.jpg
1

Though not a binary search, you could use powershell to get at least close (assuming all the images are exactly the same except the image...)

https://stackoverflow.com/questions/9552367/get-the-detail-informations-from-a-png-file-in-powershell

Basically, find the details you need to check against, and then use Powershell to search each image, then compare:

http://technet.microsoft.com/en-us/library/ee156812.aspx

You can use compare-object to check the object too. Either way should work, but the second method would be better / easier.

0

If you have an exact copy of it available, once you know the file size you can search for cat.jpg size:n.nnKB, or more specifically in bytes: cat.jpg size:nB.

If you have the file size and don't know the name, searching for just size:nB should work fine too, or at least narrow it down considerably.

3
  • That won't work if they're all the exact same size Mar 25, 2013 at 23:56
  • @AlexRamallo That is true. Mar 26, 2013 at 1:00
  • 1
    But, you can check against a few properties. Width and Height, and file size, because compression will mean that even if they are the same dimensions, the chances of them being the same filesize are very, very small. Mar 26, 2013 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .