[SVN] Recursively delete .svn folders

08.29.2007 | 12:39 am | Code

Subversion gives you a nice “export” command which will export you a clean copy of your project. However, sometimes you will find yourself in front of a deep structure of code and folders which was provided by someone who just zipped up their working copy with all the .svn folders included ;-) .

Removing these folders is easy on unix systems, by doing something like this:

rm -rf `find . -type d -name .svn`

However, this elegant solution is not possible on Windows. So, how do you do it?
Make a litte batch file with the following line and execute it.

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

13 Comments »

  1. Thank you! Saved me alot of effort

    Comment by Simon Cruise | 06.28.2008 | 11:43 am

  2. Thanks a lot. I screwed up and had to reimport my project in a new repository. This helped terrifically!

    Comment by Dennis Decoene | 08.5.2008 | 12:45 pm

  3. very nice tip to DELETE .SVN FOLDERS in WINDOWS

    Comment by Sameer | 09.12.2008 | 8:46 pm

  4. [...] which are created by tortoise svn to keep track of the repository state on the client. I found this site which provided an elegant way which precisely meets my [...]

    Pingback by ASpeak » Delete .svn folders recursively | 12.3.2008 | 10:50 am

  5. TERRIFIC!!!! THANKS

    Comment by DHIRAJ | 01.5.2009 | 9:15 am

  6. worked great. Thanks.

    Comment by chad caldwell | 02.13.2009 | 8:34 pm

  7. thanks

    for those who want to run it from Command line directly… use

    FOR /F “tokens=*” %G IN (‘DIR /B /AD /S *.svn*’) DO RMDIR /S /Q “%G”

    replace with your SVN working dir ;)

    like mine…

    FOR /F “tokens=*” %G IN (‘DIR /B /AD /S c:\svn_repository\*.svn*’) DO RMDIR /S /Q “%G”

    Comment by Ajai | 03.26.2009 | 1:57 am

  8. sorry guys… i have to repost my comment bcz of the stupid formatting :(

    for those who want to run it from Command line directly… use

    FOR /F “tokens=*” %G IN (’DIR /B /AD /S [YOURWOKRINGDIR]*.svn*’) DO RMDIR /S /Q “%G”

    replace [YOURWOKRINGDIR] with your SVN working dir ;)

    like mine…

    FOR /F “tokens=*” %G IN (’DIR /B /AD /S c:\svn_repository\*.svn*’) DO RMDIR /S /Q “%G”

    Comment by Ajai | 03.26.2009 | 1:59 am

  9. [...] what would happen if you mixed in .svn folders from a different branch?). The google helped me find this cmd.exe one-liner, and I’m simply reposting it here for [...]

    Pingback by Cleanup/delete all .svn folders « ben tsai | 06.25.2009 | 2:54 pm

  10. Thank you! Works great.

    Comment by Cimi | 11.10.2009 | 11:42 pm

  11. Thanks, worked for me!!!

    Comment by Timi | 12.18.2009 | 7:53 pm

  12. thanks for this tip

    mine uses a directory name with spaces see below

    FOR /F “tokens=*” %G IN (‘DIR /B /AD /S “D:\My Documens\urkurk 1\*.svn*”‘) DO RMDIR /S /Q “%G”

    Comment by urkurk | 12.23.2009 | 6:40 am

  13. amazing stuff thanx :)

    rH3uYcBX

    Comment by SantaBlue | 12.29.2009 | 7:27 pm

 

Leave a comment