Skip to content

Instantly share code, notes, and snippets.

@goreilly
Created May 30, 2020 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goreilly/e80a6e2e1e251773f69d3577c66c0320 to your computer and use it in GitHub Desktop.
Save goreilly/e80a6e2e1e251773f69d3577c66c0320 to your computer and use it in GitHub Desktop.
Remove duplicate files with same filename but different extension in powershell
Add-Type -AssemblyName Microsoft.VisualBasic
$items = Get-ChildItem -Path . -Recurse -Name "*.opus"
foreach ($item in $items) {
#Write-Host $item
$base = $item.Substring(0, $item.LastIndexOf('.'))
$ogg = $base + ".ogg"
#Write-Host $basename
#Write-Host $ogg
if (Test-Path -LiteralPath $ogg -PathType Leaf) {
Write-Host "Would remove" $ogg
#[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($ogg,'OnlyErrorDialogs','SendToRecycleBin')
}
#break
}
Pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment