GuideProgramming + ScriptingPowershell Delete duplicate files found with a suffix like (Copy) Updated August 11 2024
Copy to Clipboard $Folder = "E:\Recovered_Files" $ScanSubfolders = $false $SuffixForDuplicate = " - Copy" $Files = get-childitem $Folder $DeletedCount = 0 foreach ( $File in $Files ){ $MatchName = "$($File.BaseName)$($SuffixForDuplicate)$($File.Extension)" $Match = $Files | Where-Object { $_.Name -eq $MatchName -and $_.Length -eq $File.Length } if ( $Match.count -gt 0 ){ #Duplicate found! write-host "Deleting $($Match.FullName)" Remove-Item $Match.FullName -Force $DeletedCount++ } } Write-Host "Deleted a total of $($DeletedCount) file(s)."




©2024 - Some portions of this website are Copyrighted.
Your IP: 18.222.118.105     Referring URL:
Browser: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Terms and Conditions, Privacy Policy, and Security Policy