user3026965 user3026965 -4 years ago 99
PHP Question

File details: size, last modified time, md5 value, path\filename

Media archiving. Windows. PowerShell. (or by php in command line?)

Any way I can include the md5 hash value for each file? This script provides file size, last modified time, path\filename; having an md5 value would be useful. (Capability to handle entire disks, 100K+ files/many TBs, 4K video [large] files, etc. with ease (i.e., a clean and robust function].)

The results needs to be written into a .txt file and placed into the current working dir.

Get-ChildItem -Recurse | select Length,LastWriteTime,FullName | Format-Table -Wrap -AutoSize | Out-File filelist.txt

Answer Source

If you're using PowerShell v5 (maybe 4?), you can use get-filehash to compute the hash of each file. Then use that in a computed property in select-object.

Get-childitem -recurse -file | select-object length,lastwritetime,fullname,@{n="Hash";e={get-filehash -algorithm MD5 -path $_.FullName | Select-object -expandproperty Hash}}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download