Ever needed to find duplicate files on a Windows File-server? You can easily do this with a one-line PowerShell command:
This first example list the hash of the file then the path follow:
Get-ChildItem -Path "D:\data\" -Recurse | Get-FileHash | Group-Object -Property Hash | Where-Object Count -GT 1 | foreach {$_.Group | select Path, Hash} | out-file .\list_duplicate_files.txt
This version will do the same, but group every file and also show complete file path (in case the path is too long for the first example):
Get-ChildItem -Path "D:\data\" -Recurse | Get-FileHash | Group-Object -Property Hash | Where-Object Count -GT 1 | foreach {$_.Group | select Hash,Path | ft -auto } | out-file .\list_duplicate_files.txt
Comments