Tuesday, December 2, 2008
Sometimes we end up with two different versions of a video or file and dont' know if they are, in fact, different. Or, sometimes when we hand off a disc to a client they claim they can't view the video or it's "corrupted". So, here's how to compare files a simple, straight forward and built-into the Mac way.
Method #1 "MD5".
01 Launch the Terminal. (I like to hit Command + Shift + U to open the Application folder, then hit the letter T and up and down arrow from there, then hit Command + O or use Control + F3 if the terminal is already in the dock)
02 OPTIONAL STEP: Hit Command + COMMA to open the Terminal's Preferences and goto Settings > Window > Background Color. In the color window that opens set the transparency to something like 60%. Close the preferences.
03 In the Terminal type exactly, without the quotes "md5" in lowercase.
04 Hit Spacebar.
05 Drag the first of the files you want to directly compare into the terminal window. You'll end up with something like:
06 Hit Return.
After a moment (bigger files take longer) you'll see a number appear as a result. Something like: aa3f30d5e8977965702c4acc83f645da
Now, do the exact same thing with the file you want to compare this first file with. But why did you mess with the preferences to alter the transparency of the window? A quick trick to compare the numbers, since they're so long, is to run md5 in two separate Terminal windows, and since they're transparent -or at least translucent-, overlap them and see if the images of the generated numbers match.
If the numbers are identical, the files are identical.
If you need to generate md5 sums on many files in one directory, from a fresh Terminal prompt, type "cd" then hit spacebar, drag the directory (folder) into the terminal window and hit Return to change it to that directory. Then type "md5 *" and hit enter (that's an asterisk after a space) and you'll see a list of md5 numbers.
Method #2 "CMP".
01 Launch the Terminal.
02 Type "cmp -l" (that's a lowercase letter L)
03 Drag the first file you want to compare into the window.
04 Drag the second file, the one you want to compare against the first, into the window. You'll end up with a long line of paths and directories to the two files.
05 Hit Return and wait a while. There is absolutely no indication that anything is happening while it compares them. If you return to the standard prompt, the two files were identical. If it outputs some sets of numbers the files are different. Be patient, it can take a while to compare large files.
"cmp" will compare the files byte-by-byte and let you know if they are different. The difference it will spew out won't make much sense to the average viewer, but the importance is that it'll let you know they are different.
Use both command-line tools to be even more sure of the files are the same or not.