Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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"

share|improve this question
    
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 '13 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 '13 at 10:14

3 Answers 3

up vote 1 down vote accepted

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
share|improve this answer

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...)

http://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.

share|improve this answer

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.

share|improve this answer
    
That won't work if they're all the exact same size –  AlexRamallo Mar 25 '13 at 23:56
    
@AlexRamallo That is true. –  Louis Mar 26 '13 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. –  AthomSfere Mar 26 '13 at 15:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.