I work with multiple projects, and I want to recursively delete all folders with the name 'bin' or 'obj' that way I am sure that all projects will rebuild everything (sometimes it's the only way to force Visual Studio to forget all about previous builds).
Is there a quick way to accomplish this (with a .bat file for example) without having to write a .NET program?
Best Answer
This depends on the shell you prefer to use.
If you are using the cmd shell on Windows then the following should work:
If you are using a bash or zsh type shell (such as git bash or babun on Windows or most Linux / OS X shells) then this is a much nicer, more succinct way to do what you want:
and this can be reduced to one line with an OR:
Note that if your directories of filenames contain spaces or quotes, find will send those entries as-is, which xargs may split into multiple entries. If your shell supports them,
-print0
and-0
will work around this short-coming, so the above examples become:and:
If you are using Powershell then you can use this:
as seen in Robert H's answer below - just make sure you give him credit for the powershell answer rather than me if you choose to up-vote anything :)
It would of course be wise to run whatever command you choose somewhere safe first to test it!