HashCompare: Script Command to compare file hashes

It looks like the Duplicate File utility might be sufficient for my needs.

To be clear I've been doing what I need with Opus already using the MD5 column and some fussing around with the layout whenever I need this. I was simply looking for a simpler way to accomplish the confirmation that 2 files which should be identical have identical checksums.

Thanks,

Jason

@Jason glad that helps. I do see the use of your idea of a quick command to compare two files directly. steje's script is probably not too hard to tweak for someone who knows VB and the scripting interface — not me, but thought I'd peek inside. Strangely when I unzipped the osp file, my text editor showed the script with Chinese characters—it assumed a UTF-16 encoding. Converting it to UTF-8 it displayed it properly.

@jproos, playful and TheSeeker...

I've updated the root post with a fair overhaul to the script... the ONLY change to the old behavior is some adjusted messaging. The update otherwise adds a FILE option that will compare the hash values of two selected files like you had mentioned, which I find very useful for quick comparisons myself - so THANKS for suggesting it!

Read the notes on the FILE comparisons progress dialog snafu... If there is interest, I will also post another update to allows comparison of files in different folders (file from source file display against file from destination file display). The command currently works against only two files in the same folder - which I admit isn't ideal.

Cheers - I'll take a look.

Update to v1.2.5.

2016-01-28: v1.2.5 - Added support for comparing two files from different tabs (in the same or different lister), since I very often have files who's hashes I want to compare in different folders and even different drives; and moving them to the same folder the way the first use of the FILE option worked isn't always practical. Also added a TOFILE option to write the calculated hash value out to a file named .. So the MD5 hash for foo.bin will be written to foo.bin.MD5. If multiple files are selected, then each file gets it's own hash file.

I also added some notes to the root post about having to fall back to a simple rather than full progress dialog when comparing two files hashes against each other.

I now use PowerShell to compare files:

Get-FileHash *.iso | Format-List

The above code will produce the following for the two ISO files I have in this particular directory (hashes are the same as it's the same file):

Algorithm : SHA256
Hash      : 9D0CD2C98C5912463E7A64986EF24DC421D973376E8A35E392038CB5F4693AAB
Path      : C:\Users\Seeker\Downloads\F23-x86_64-WORK-20160303.iso

Algorithm : SHA256
Hash      : 9D0CD2C98C5912463E7A64986EF24DC421D973376E8A35E392038CB5F4693AAB
Path      : C:\Users\Seeker\Downloads\test.iso

SHA256 is used by default. If wanting SHA1, SHA512 or MD5, simply use the -Algorithm parameter:

Get-FileHash -Algorithm SHA1 *.iso | Format-List

Produces the following:

Algorithm : SHA1
Hash      : 1E71B6FBB10BFAEE6258FD93A3CD60B2DA4146F4
Path      : C:\Users\Seeker\Downloads\F23-x86_64-WORK-20160303.iso

Algorithm : SHA1
Hash      : 1E71B6FBB10BFAEE6258FD93A3CD60B2DA4146F4
Path      : C:\Users\Seeker\Downloads\test.iso

More here.

Edit: Added some more examples. If too off-topic, please let me know.

This script broke for me. It complained about:

HashCompare.vbs: Initializing...
HashCompare: Error at line 221, position 7
HashCompare: Error 0x80004005

...which was a DOpus.SetClip without any arguments. I changed it to DOpus.SetClip() and it worked. I actually changed two of the three instances where there was no (), which were lines 221 and 436. I somehow missed fixing the one on line 130 and it still ran fine. I'm not much of a VBSer, so I don't know the rules about missing parentheses.

@DesertDwarf... weird. Thanks, I'll get around to posting an update to the root thread soon.

@TheSeeker... yeah, value there in hash types not supported by Opus. I don't think it's too off topic at all. People who are interested in this script might very well be also wanting support for other hash types. I wonder if I can capture that cmdlets output in a script such that I could incorporate the 'other' hash types not supported by Opus into the script. Hmmm... I'd keep the native Opus stuff thats in here already since I can take advantage of some caching on repeat comparisons though.

Posted a minor update to fix the DOpus.SetClip error..

Add a feature to ingnore ":" and the text before it in clipboard is needed, think about it.

Script is unreliable. Does not clear cache (saved hashes) between executions in same dopus session.
Test:
make 2 identical files - compare. result: hashes match
make change to one file - compare again. result: hashes match

Does doing an F5 refresh on the folder fix it? (I am not sure exactly what the script does, but if it works how I suspect it does, that should make it recalculate the hashes.)

Yes, refresh fixes it, thx.

Ok, fixed the script itself by adding
objCmd.RunCommand "Go REFRESH"
at line 89 in hashcompare.vbs

Should I add some delay also there, to be sure that refreshing is finished before script continues to hashing (Clipboard COPYNAMES=hash6) or dopus handles this without the possibility of failure?

Please link your account and I can investigate whether or not that is needed for you.

Hi,

  1. When I select 2 files (in the same folder) and run HashCompare FILE MD5 through the context menu of the 1st selected file I get the error at line 219 : Opus.SetClip(). The command needs to be run on the second selected file.

  2. When I select 2 files (one in source and the other in destination panel) and run HashCompare FILE MD5 through the context menu of the one of the selected file either I get the error at line 219 : Opus.SetClip(); either it reports hashes are different even if they are not. Once a while, it works as expected. It seems it needs a refresh of both lists (source & dest) even if the files to compare are in the same one. Try to compare the same 2 files multiple times to test.

  3. Selecting a file A, I produced a A.MD5 file with the command HashCompare TOFILE. Then when I select file A, how to compare it with the MD5 file? My solution is to use another script addin.

It seems it works the best only to compare with clipboard content.

Rebooted my laptop just a minute ago only to see this... I'll contact the author right away to see if... oh wait, it's ME, LMFBO!

Defender is complete garbage these days. :frowning:

Adding the .txt extension to the end of the scripts in the .osp file may make it leave them alone, although I'm only guessing. (e.g. .vbs.txt or .js.txt.)

There are a lot of us very experienced computer users that like other programs, including ESET's NOD32.

1 Like

Any plans on implementing SHA-256/512. For example by using the DOpus.FSUtil?