Removing Unwanted Files with PowerShell
— powershell, windows — 1 min read
Sometimes after using gVim on Windows, I end up with temporary files.
1.\content\5-minute-intro-to-gradle.markdown2.\content\5-minute-intro-to-gradle.markdown~3.\content\command-line-diff-for-windows.markdown4.\content\command-line-diff-for-windows.markdown~
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
.