Skip to content

Instantly share code, notes, and snippets.

@alfredmyers
Last active February 8, 2019 22:19
Show Gist options
  • Save alfredmyers/0d96df2dd9388d8256538478b3c7436d to your computer and use it in GitHub Desktop.
Save alfredmyers/0d96df2dd9388d8256538478b3c7436d to your computer and use it in GitHub Desktop.
Removes file duplicates based on content's hash
$fork = "C:\Users\Alfred\Desktop\MyBooks" # Directory possibly containing duplicate files
$repo = "C:\Books" # Directory containing master files
$repoHashes = (Get-ChildItem $repo -Recurse -File | Get-FileHash).Hash
Get-ChildItem $fork -Recurse -File |
Where-Object { $repoHashes.Contains(($_ | Get-FileHash).Hash) } |
Remove-Item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment