Batch script - calculating md5 hashes for all files in c: drive

1

1

I'm trying to figure out how to setup specific location where I want to start calculating hashes ? Let's say I would like to start calculating md5 hashes for all files on c:\ drive and files included in folders as well.

set mypath="C:\"

for /F "usebackq delims=" %%z in (`dir /b /s /a-d /on "%mypath%"`) do md5sum "%%z" >> "C:\Temp\system_hashes.txt"

Not sure what is wrong with above code ?

Lack of threat

Posted 2016-11-13T01:37:53.563

Reputation: 11

Why do you have "s around C:\? – DavidPostill – 2016-11-13T10:23:57.867

yeah my fault, already fixed but still doesn't work. – Lack of threat – 2016-11-13T12:48:22.790

What makes you think it's not working? Hint: the dir part of the for command takes a very long time to finish ... – DavidPostill – 2016-11-13T12:52:03.780

... not to mention each md5sum, given "larger" files. – Hannu – 2016-11-13T14:56:58.573

But while above function is running, the file system_hashes.txt in path C:\Temp\ is not created. I believe that this file should be created at the beginning, and then any new md5 hash will be written. That is why I'm thinking that it doesn't work. It works for narrow path like C:\folderA or something, but for entire disk like C: looks like suspended. Is there any option to speed up this function ? – Lack of threat – 2016-11-13T15:58:39.980

Then for a test don't start at the root but a small folder and result should show up at once. – LotPings – 2016-11-13T20:50:05.377

No answers