Skip to content

Steve Hill

Removing Unwanted Files with PowerShell

powershell, windows1 min read

Sometimes after using gVim on Windows, I end up with temporary files.


I'd really like to remove all the files in .\content that end in ~. If find on Unix immediately comes to mind, PowerShell's Get-ChildItem will feel right at home.

1Get-ChildItem -Path .\content -Filter *~ -File | Remove-Item

Our directory is free from unwanted files!

Note It's also possible to directly use the Remove-Item command, but by using Get-ChildItem we can safely fine-tune our query before piping it to the destructive Remove-Item.