Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://pastebin.com/Qq43NRQF
- # PowerShell solution to remove duplicate files
- $target = "C:\adjust\path"
- $Host.UI.RawUI.WindowTitle = 'Duplicate File Remover'
- $start = (Get-Date)
- $i = 0
- $file_list = New-Object System.Collections.ArrayList
- (Get-ChildItem -Path $target -File -Recurse) | ForEach-Object {
- $hash = (Get-FileHash $_.FullName).Hash
- if ($file_list.Contains($hash) {
- Remove-Item $_.FullName
- Write-Host Removed duplicate: $_.FullName
- $i++
- } else {
- $file_list.Add($hash) > $null
- }
- }
- Write-Host "`n`n`nRemoved $i duplicate(s)!`nDuration: "((Get-Date) - $start).ToString("hh\:mm\:ss\.fff")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement