Page 4 of 5

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 01 Aug 2020 02:32
by Michael513
Thanks for the batch file

I want to do something that's simpler and less complex, ideally, I want the process to be like

Code: Select all

set correctMD5=c6e160e565a0b5764cf70ed258b9ffd9
if "C:\program\config.ini" equals %correctMD5% goto :step1
if not "C:\program\config.ini" equals %correctMD5% goto :step2

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 01 Aug 2020 14:11
by dbenham
There is nothing complicated about it - the original post in this thread shows the basic technique. Just a few minor tweaks to get your behavior:

Code: Select all

echo %correctMD5% *C:\program\config.ini | hashsum /c /q && goto :step1 || goto :step2
Just be sure to put an asterisk before your file path, and don't use any quotes, even if there are spaces in the path. Windows automatically strips any trailing spaces from the name.


Dave Benham

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 01 Aug 2020 15:05
by Michael513
I just didn't know how to connect the two codes together, thank Sir Dave!

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 08 Oct 2020 08:02
by Squashman
Michael513 wrote:
01 Aug 2020 15:05
I just didn't know how to connect the two codes together, thank Sir Dave!
Dave, two questions.
1) When were you knighted?
2) When did you move to England?

:mrgreen:

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 17 Jan 2021 02:15
by balubeto
What is the latest complete and working version of this script?

How do I choose which type of hash to produce?

From the command line, what is its syntax?

Thanks

Bye

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 17 Jan 2021 06:21
by dbenham
The very first post of this thread always has the most recent version (currently v1.6). That version should work as long as all characters in filenames are supported by your active code page. I did not incorporate andresp's suggested changes to support all unicode charcters in file names

As for the rest - read that first post, and also the built in help.


Dave Benham

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 17 Jan 2021 09:50
by balubeto
dbenham wrote:
17 Jan 2021 06:21
The very first post of this thread always has the most recent version (currently v1.6). That version should work as long as all characters in filenames are supported by your active code page. I did not incorporate andresp's suggested changes to support all unicode charcters in file names

As for the rest - read that first post, and also the built in help.


Dave Benham
How do I incorporate the andresp code into the main script as well?

Thanks

Bye

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 17 Jan 2021 23:04
by Squashman
balubeto wrote:
17 Jan 2021 09:50
How do I incorporate the andresp code into the main script as well?

Thanks

Bye
I am going to take a wild guess and say download the code that andresp posted

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 18 Jan 2021 02:04
by balubeto
Squashman wrote:
17 Jan 2021 23:04
balubeto wrote:
17 Jan 2021 09:50
How do I incorporate the andresp code into the main script as well?

Thanks

Bye
I am going to take a wild guess and say download the code that andresp posted

Now, I test it.

Thanks

Bye

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

Posted: 18 Jan 2021 14:15
by Compo
balubeto wrote:
18 Jan 2021 02:04
Now, I test it.

Thanks

Bye
Test this

Thanks

Bye

Re: HASHSUM.BAT v1.7 - emulate md5sum, shasum, and the like

Posted: 19 Jan 2021 13:21
by dbenham
I've edited the first post in this thread to version 1.7.

I adopted andresp's idea of using code page (CP) 65001 (UTF-8) to support file names that contain characters that are not in your active code page. However, the feature has not been adequately tested in my mind, so I only activate CP 65001 if you use the new /U option - and the original code page is restored upon completion.

I have a couple concerns:

1) I attempt to capture the current code page so I can reset the code page at the end. However I'm not sure that the code is robust enough to work with all languages - the CHCP output may change for different languages and break my code.

2) There are reports that CP 65001 breaks some legacy programs like FIND and MORE. So I replaced all three calls to FIND with FINDSTR /L. But I'm worried that I originally used FIND for a reason. FINDSTR is finicky/buggy, and I'm not 100% confident it will always work properly in this context.

Please report any problems with the new /U option here.


Dave Benham

Re: HASHSUM.BAT v1.7 - emulate md5sum, shasum, and the like

Posted: 19 Jan 2021 14:29
by Compo
dbenham wrote:
19 Jan 2021 13:21
I have a couple concerns:

1) I attempt to capture the current code page so I can reset the code page at the end. However I'm not sure that the code is robust enough to work with all languages - the CHCP output may change for different languages and break my code.

Dave Benham
We discussed that here, Dave, and if I remember correctly the following seemed to be the the agreed method, (modified to be directly replaceable in your code):

Code: Select all

for /f "tokens=*" %%A in ('chcp') do for %%B in (%%A) do set "chcp=%%~nB"

Re: HASHSUM.BAT v1.8 - emulate md5sum, shasum, and the like

Posted: 19 Jan 2021 21:32
by dbenham
Thanks Compo (and Carlos and the rest of the team that developed and tested that CHCP method). That helps a lot - I feel much better about capturing the active code page now.

I've updated the first post in this thread to version 1.8 with the recommended change.


Dave Benham

Re: HASHSUM.BAT v1.8 - emulate md5sum, shasum, and the like

Posted: 20 Jan 2021 03:31
by balubeto
Does this script work even if the files were located in a directory on a network drive?

Thanks

Bye

Re: HASHSUM.BAT v1.8 - emulate md5sum, shasum, and the like

Posted: 20 Jan 2021 06:08
by dbenham
Easy to test - you tell me.

bye