Windows 10 20H2 and hash file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

Windows 10 20H2 and hash file

#1 Post by balubeto » 16 Jan 2021 12:11

Hi

Using Windows 10 20H2, how can I create a script that, starting from a local or network directory, parses all its subdirectories creating a text file containing all the file names with the corresponding SHA1 hashes next to them?

Thanks

Bye

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: Windows 10 20H2 and hash file

#2 Post by Compo » 16 Jan 2021 21:27

One possible, but potentially slow solution, is to use the built-in certutil utility.

Code: Select all

@(For /F Delims^=^ EOL^= %%G In ('Dir /B/S/A-D "E:\SourceDir"')Do @If %%~zG==0 (Echo da39a3ee5e6b4b0d3255bfef95601890afd80709 *%%G)Else For /F %%H In ('%__AppDir__%\certutil.exe -hashfile "%%G"^|%__AppDir__%\find.exe /V ":"')Do @Echo %%H *%%G)>"%UserProfile%\Destination\hashed.txt"
Just change E:\SourceDir and %UserProfile%\Destination\hashed.txt to your own source and destinations.

*Please note balubeto: I have seen many of your questions before, and will not be making any changes, or answering any questions regarding this snippet.*

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Windows 10 20H2 and hash file

#3 Post by Squashman » 16 Jan 2021 22:23

balubeto wrote:
16 Jan 2021 12:11
Hi

Using Windows 10 20H2, how can I create a script that, starting from a local or network directory, parses all its subdirectories creating a text file containing all the file names with the corresponding SHA1 hashes next to them?

Thanks

Bye
Almost 10 years on these forums and you still pretty much just ask a question without ever even making an attempt at solving the problem yourself. People are more inclined to help other people when they have shown some effort of solving the problem on their own.
I bet if you would have searched the forums you might have found: HASHSUM.BAT

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: Windows 10 20H2 and hash file

#4 Post by Compo » 17 Jan 2021 11:00

balubeto, as you have definitely read the responses to your question, (because you've already posted in the thread linked to in the second response), and taking account that responses are for the community, not just for you, I would have expected you to try the answer I provided and posted with relevant feedback.

I have, since posting my answer, checked the code I provided in Windows 10 Pro, Version 20H2, (build 19042.746). The exact version you provided in your question title and body, and verified that the output is returned as intended.

Please show me the courtesy of trying my code, and letting the community know whether it achieves the intended aim, thank you.

Post Reply