Wednesday, August 20, 2014

PS: Remove folder recursively

Recently I have to clean up my .Net solution with a long list of projects. One of cleanup is to remove all bin and obj folders. It is very tedious doing it manually.

I turn to Powershell Script to find a quick way. Soon I got my solution, only two lines of codes and I could do in PS console interactively:

Here is the function:

$a = Get-ChildItem -Path H:MyRepository\Solution\ -Recurse | Where-Object {$_Name -Match '^obj$' }
$a | { rm -r $_.FullName }

Repeat the same steps to remove bin folders.

0 comments: