Command to recursively remove all .svn directories on Windows

If you want to delete all sub folders named .svn in windows then create batch file with this content:

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (
rd /s /q "%%i"
)

save it in a file del_All_Dot_SVN_Folders.cmd . Run it. You're done.

Thanks to http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/

Remember the above code has .svn whereas the code in the link has only *svn so its better to have the .svn to not accidentally have undesired effect.


Do this in PowerShell.

NOTE: This is recursive so be sure you are in the right directory!

gci -fil '.svn' -r -force | ri -r -force

Here is the rest of my source tree cleanup script.

gci -fil 'bin' -r -force | ri -r -force
gci -fil 'obj' -r -force | ri -r -force
gci -fil '_ReSharper*' -r -force | ri -r -force
gci -fil '*.suo' -r -force | ri -r -force
gci -fil '*.user' -r -force | ri -r -force

Use the svn export command to export a Subversion working copy into a new "clean" directory structure that doesn't have the .svn directories.


Make a litte batch file with the following line and execute it from the parent folder under which there are .svn directories.

FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G"

You can also issue the line below straight from the Command Prompt:

FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%G"