Friday, June 20, 2008

Powershell: Remove all hidden .svn folders

To delete all .svn folders under the current directory execute the following Powershell command. To actually delete the folders, remove the -WhatIf switch at the end.

get-childitem -recurse -force | Where-Object { $_.PsIsContainer -and $_.Name -match ".svn" } | Remove-Item -recurse -force -WhatIf

Powershell: Find .svn folders

How do you find all .svn folders under the current folder? The main challenge I had was that the .svn folder did not show up in any variation of Get-ChildIem call I was trying until I found that the -force switch is needed to show hidden files.

The call is as follows:

Get-ChildItem -recurse -force | Where-Object { $_.PsIsContainer -and $_.Name -match ".svn" } | select fullname