Command line tool to delete folder with a specified name recursively in Windows?

Solution 1:

Similar to BlackTigerX's "for", I was going to suggest

for /d /r . %d in (_svn) do @if exist "%d" rd /s/q "%d"

Solution 2:

Time to learn some PowerShell ;o)

Get-ChildItem -path c:\projet -Include '_svn' -Recurse -force | Remove-Item -force -Recurse

The first part finds each _svn folder recursively. Force is used to find hidden folders. Second part is used to delete these folders and their contents. Remove commandlet comes with a handy "whatif" parameter which allows to preview what will be done.

PowerShell is available for Windows XP and Windows Vista. It is present on Windows 7 and on Windows Server 2008 R2 by default.

It's a MS product, it's free, and it rocks!

Solution 3:

For inclusion/invocation from within a BATCH file use (say for removing Debug and Release folder):

for /d /r . %%d in (Debug Release) do @if exist "%%d" echo "%%d" && rd /s/q "%%d"

double % are required within a batch file to work as escape chars. Else it reports error of syntax.

Thanks.

Solution 4:

for /f "usebackq" %d in (`"dir _svn /ad/b/s"`) do rd /s/q "%d"

http://ebersys.blogspot.com/2008/07/recursively-delete-svn-folders-easy-way.html

Solution 5:

In Windows? If you are using tortoiseSVN you can use the export command to export a copy of the project without the .svn/_svn folders.