I would like to compare files on two different computers using hashes, ideally SHA2-512. Lacking a tool for the specific purpose, I plan to perform this comparison in a spreadsheet. So: one spreadsheet tab for filename plus SHA 512 hash on computer A; another tab for filename plus SHA-512 hash on computer B. Then run lookups to find inconsistencies between the two lists.
To make that happen, I need a tool that will output a single line stating the name of a file (with path) and only its selected hash (in my case, not CRC32, MD5, etc.). The input command may specify an entire (optionally recursed) folder or a specific file for hashing. The output will presumably be a .csv or .txt file listing the files and their SHA512 hashes. I want a command-line (not GUI) solution so that I can select files that may not conform to a simple pattern (e.g., *.wav).
I have so far not found a batch solution to this. Possibly there is a PowerShell solution, but I don't know anything about PowerShell. I have experimented with a few canned tools (e.g., hashsum.bat; Nirsoft's HashMyFiles) without success. I did submit a feature request for Sigcheck a few years ago (see https://social.technet.microsoft.com/Fo ... uggestions); apparently that request is still in Sigcheck's backlog.
This seems like something simple and obvious, for which there is surely a simple batch solution. But if there is, I'm not finding it. So ... suggestions welcome.
Seeking one-line output: filename plus hash
- Simon Sheppard
- Posts: 127
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: Seeking one-line output: filename plus hash
PowerShell should be capable of doing this without any other utilities, see these two cmdlets:
https://ss64.com/ps/get-filehash.html
https://ss64.com/ps/export-csv.html
If you can write batch files, PowerShell is much easier to pick up - the only hard part is remembering all the different cmdlets.
https://ss64.com/ps/get-filehash.html
https://ss64.com/ps/export-csv.html
If you can write batch files, PowerShell is much easier to pick up - the only hard part is remembering all the different cmdlets.
Re: Seeking one-line output: filename plus hash
OK. Here's what I've got so far:
For some reason, it's stating only the hash, not the path. What am I doing wrong?
Code: Select all
Get-FileHash -Algorithm SHA512 -Path (Get-ChildItem "D:\Current\*.*" -Force -Recurse) | Select-Object Hash,Path | Format-Table -Wrap -Autosize
- Simon Sheppard
- Posts: 127
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: Seeking one-line output: filename plus hash
I've added an example to the https://ss64.com/ps/get-filehash.html page