'Generate Checksum for a directory in windows
I want to create checksum for directory and I am following the answer given on this post
But the problem is that it is creating checksum for each file in the directory and I want to create a checksum for the directory.
I am newbie in this kindly help me out. Thanks.
Solution 1:[1]
@echo off
set directory=.
dir /s "%directory%" >"%temp%\filelist"
md5 "%temp%\filelist" >> output.txt
del/q "%temp%\filelist"
- a recursive list of all files in the specified directory is written in a temporary file
(use.for current directory,%~1for the first command line parameter) md5hash of this file is appended tooutput.txtin current directory- the temporary file is deleted
Solution 2:[2]
The powershell way would be the following:
Get-ChildItem -Recurse . -File | Get-FileHash -Algorithm MD5 | Format-Table -Wrap | Out-File -Append <File_Path>
or if you only want the file hashes:
Get-ChildItem -Recurse . -File | Get-FileHash -Algorithm MD5 | Select-Object Hash | Format-Table -HideTableHeaders | Out-File -Append <File_Path>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | wOxxOm |
| Solution 2 | Peter Csala |
