Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Find files in folders starting in the current folder that match the name & create csv with file properties, SHA256 checksum & file size in MB (which is easier to read than bytes)
- ## Use to help find duplicate files which will have the same hash
- ls *folderpattern* -force -Recurse | Where { -Not $_.PSIsContainer -and $_.Length -ge 100MB } | select *,@{n='Size (MB)';e={ [math]::round( $_.Length / 1MB , 1 ) }},@{n='Hash';e={Get-FileHash $_.FullName -EA continue|select -expand Hash}} -exclude PS* | export-csv -NoTypeInformation .\files.and.hashes.csv
- ## Import hashes back into PowerShell object
- $hashes = import-csv .\files.and.hashes.csv
- ## Group by hash so we find files (>100MB) which are the same/duplicate
- $hashes|where { -Not [string]::IsNullOrEmpty( $_.Hash ) }|select fullname,hash|group hash|where count -gt 1|sort count -desc|select count,@{n='File';e={($_.group|select -expand fullname) -join "`n"}}|ft -AutoSize -wrap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement