I have several thousand duplicate files (jar files as an example) that I\'d like to use powershell to
Keep a dictionary of files, delete when the next file name was already encountered before:
$dict = @{};
dir c:\admin -Recurse | foreach {
$key = $_.Name #replace this with your checksum function
$find = $dict[$key];
if($find -ne $null) {
#current file is a duplicate
#Remove-Item -Path $_.FullName ?
}
$dict[$key] = 0; #dummy placeholder to save memory
}
I used file name as a key, but you can use a checksum if you want (or both) - see code comment.