I want to write a batch script that has the ability to generate and verify md5 hashes of an entire directory tree. Is there any program like this for windows?

I can find many md5 programs, but they don't verify or recur.

  • 1
    well if you have a command line program that generates then you can take the output of it and use it to verify. And you can use the FOR /F command to get it to apply to a load of files or a directory. – barlop Feb 17 '15 at 2:23
  • i'd probably break down this question into subquestions of A)How do I write a program that takes a file,(could be a file listing files one per row) and adds a second column to it is some sequence on rows 1-5 respectively, the sequence could be 1,2,3,4,5 Then ask B)How do I write a program that checks that the second column of the file reads 1,2,3,4,5 – barlop Feb 17 '15 at 2:44
  • Then use that principle..introducing md5 into it. Have a batch file that uses your md5 program on a file listing files with their full paths, and adds a column to it with the md5 hashes. And then have your batch file with another option, check that the file has a list of md5s you specify - that could be checking that file against another file. – barlop Feb 17 '15 at 2:46

so if you are familiar with the command line here are a few tools you can try:


From: http://web.archive.org/web/20151229001926/http://malektips.com:80/filelist-output-directory-csv-spreadsheet-database.html

The original URL no longer works, so the above uses the wayback machine. If you click the link that takes you to the download site it will also use the wayback machine so here is a direct link that seems to still work: https://www.jam-software.com/filelist/

filelist /?

FileList V2.0

Prints a list of all files in a file system branch

FILELIST [/OPTION] [/FILTER pattern1;pattern2;...] Path [>list.csv]

/OWNERS       Adds a coluimn with the file owners (slower)
/NOHEADER     Leaves out the column headers and only prints the raw data
/ATTRIBUTES   Includes the attributes that are set for each files
/MD5          Adds a column wit the MD5 checksum of each file
/AUTHORS      Additionally extracts name of the author from MS Office documents
/LASTSAVEDATE Additionally extracts the last save date from MS Office documents
/FILTER       Allows to specify one or more filters, separated with semicolons

For example: filelist /md5 C:\temp > list.csv

Add new files then run again filelist /md5 C:\temp > list2.csv 

or md5deep from http://md5deep.sourceforge.net/start-md5deep.html

 md5deep.exe -r C:\temp >> md5hashes1.txt modify files and run again
 md5deep.exe -r C:\temp >> md5hashes2.txt

now just compare list.csv with list2.csv either in excel or with any diff utility (Windifff for example)

otherwise go for:

MD5summer from http://www.md5summer.org/


hksfv from http://www.big-o-software.com/products/hksfv/

| improve this answer | |

Why reinvent the wheel? Since you specifically said you were looking for a Windows app, I recommend HashCheck Shell Extension

It can do all that you ask and is very light on resources.

| improve this answer | |
  • 4
    -1 He said command line. If you want to suggest a GUI answer then make that a comment, because it doesn't answer the question he asked. If he decides on GUI then he should make a new comment prompted by you making a comment, but you shouldn't write an answer that doesn't address the question he asked. This is a database of questions and answers meant to be useful for people other than just the questioner. So it's important that the answer addresses the question even if the questioner meant something else. If the questioner meant something else he should edit or ask another q. – barlop Feb 17 '15 at 2:41

I don't think you can do this sorry. An md5 hash is a hash of a a stream of bytes, but a directory tree is not a stream of bytes. A folder is an index of files (which are streams of bytes) and other folders. Now technically folders are just files themselves, but there is no "predifined" ordering for all the files, so I do no think it is possible.

So instead I think you first need to encode the directory into a single stream of bytes (i.e. file). A command line version of zip or winRar will accomplish this. If speed is an issue, there are options to not actually do any compression. There's probably a windows port of tar as well, or maybe even a windows native equivalent (.cab files?). I'd probably go with 7zip and use the comamndline 7z.exe (included in installer)


So your script could create the single file, and then get the MD5 hash of that. And then your script could delete the single file. Not exactly what you want, but I think its your best option.

| improve this answer | |
  • It's a good point that md5 won't check the tree structure itself, but you could have a list of files with full paths, and their md5 has. Interesting idea-zip, but i'd wonder if they ever change the algorithm very slightly or compress it slightly differently, then the hash would change. I remember pkzip for example had options like pkzip -ex (-ex was extreme compression). – barlop Feb 17 '15 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.