Powershell: How to recursively delete files based of file extension?

File this under “took me WAY too long to figure out how to do”.

I just finished doing a Git merge, and ran into an issue where my working folder was polluted with .orig files.

I wanted to recursively delete all the .orig files. That is apparently harder than it sounds, because it took me 15 minutes to figure out the correct command line.

So you don’t go fumbling like I did:

Get-ChildItem . -recurse -include *.orig | remove-item

Replace . and *.orig accordingly. Have fun!

Originally published on 2016-07-15 in Development

Enjoy this article? Let's keep in touch

I really appreciate you taking the time out of your schedule to read this post. I like to keep my friends updated on new articles and also spawn discussions here and there.

If you'd like to keep in touch, please subscribe below. And I promise, no more than 1 email per week (if even that).