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

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


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

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


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!


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.