How can I generate an MD5 sum for a folder on Windows?
There are several posts about generating MD5 sums for files and/or folders on various Windows platforms. However, none of these worked for me. I tried:
- Windows CertUtil:
CertUtil -hashfile myFileName MD5returns "Access is denied" on all folders (mycmdis running with admin privileges), - HashTab: does not show up in the Properties dialog in Explorer as advertised,
- Summer Properties: does not show up in the Properties dialog either,
- HashCheck: does not allow MD5 for folders, only files,
- md5checker: does not compute the MD5 of the entire folder (only files in it).
At this point I am starting to get a bit desperate. Please note that I am using Windows 7 x64.
For info, if possible, I am trying to find a tool that would allow something like this in Linux:
find DIR -type f -exec md5sum {} \; | sort -k 2 | md5sum 5 7 Answers
None of these quite did what I needed so I came up with this alternative...
@echo off
for /R . %%f in (*.*) do ( echo | set/p="%%f - " certutil -hashfile "%%f" MD5 | findstr /V ":"
)Outputs in the format "<Path><Filename> - <Hash>" at one line per file.
If you want to use a GUI, I can recommend Fsum Frontend.
Fsum Frontend is a free and easy-to-use tool that allows to compute message digests, checksums and HMACs for files and text strings. It supports drag-and-drop and you can handle multiple files at once. The checksum generated can be used to verify the integrity of the files.
It supports 96 algorithms: [...] md5 [...]
As the name implies, Fsum Frontend is a GUI for (among others) SlavaSoft fsum.
A fast and handy command line utility for file integrity verification. It offers a choice of 13 of the most popular hash and checksum functions for file message digest and checksum calculation.
Its features include:
3
- Possibility to act recursively. FSUM can operate not only on files from a specific directory, but also on files from all subdirectories of the specified directory;
- Work with large size files. (Tested on file sizes of up to 15 GB);
- Full compatibility with md5sum utility
You can achieve the equivalent to your Unix command (minus the sorting) with the following:
for /R . %f in (*.*) do @certutil -hashfile "%f" MD5You can change the dot (.) for whatever folder you want to recurse from, and the *.* to whatever file mask you need in order to narrow down your file set.
PowerShell provides loop statement, some people may prefer this syntax
foreach($f in dir){ certutil -hashfile "$f" md5}
Reference:
2Late to the question but finding only unaccepted answers here is what I have found:
function Get-FolderHash ($folder) { dir $folder -Recurse | ?{!$_.psiscontainer} | %{[Byte[]]$contents += [System.IO.File]::ReadAllBytes($_.fullname)} $hasher = [System.Security.Cryptography.SHA1]::Create() [string]::Join("",$($hasher.ComputeHash($contents) | %{"{0:x2}" -f $_}))
}Copy and paste this code to PowerShell console and type:
Get-FolderHash "C:\CustomFolder"Runtime may vary depending on folder contents.
HashCheck Shell Extension (archive) can be used to get a hash of a directory. This can be done by:
- Using HashCheck on the directory.
- This will generate a
.md5file which contains a listing of the hashes of each file in that directory, including all files in sub-directories. - Use HashCheck again on the
.md5file it generated above. - This final generated
.md5file contains a hash of the entire directory.
If you have Python 3 installed, you could use my pyfstools package for that. Quick usage:
$ pip install git+
...
$ python -m pyfstools hash --algo md5 .
dir 88c17b149c1d9fef50f642b698cef9e6