[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"

32 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

  14. [...] gregs on Mar.22, 2010, under *nix, debian, os x I new it was possible, just never took the time to look it up. PLAIN TEXT [...]

    Pingback by Recursive delete - gregs | 03.22.2010 | 6:30 am

  15. Peter, thanks a lot !!!! I did the same that you mentioned in here, This is superb! Thanks a lot again

    Comment by Ajeesh | 08.4.2010 | 8:08 am

  16. thanks!

    Comment by ds | 08.13.2010 | 12:01 pm

  17. Thank you very much. this works good.

    Comment by Nagarajulu | 09.2.2010 | 1:00 pm

  18. It’s easier and more intuitive to so do a windows search for “.svn” and delete the result. Just make sure to go into “More Advanced Options” to include hidden files/folders in the result.

    Comment by ds | 10.19.2010 | 10:28 pm

  19. This does not seem to work for me on Windows 7 machine. Has anyone tried this on Windows 7.

    Comment by sumit | 02.18.2011 | 2:11 am

  20. I’ve been trying this on Windows 7 and this works correct. Do you get some errors?

    Comment by Snakehit | 03.6.2011 | 2:25 pm

  21. This is great,
    can you please explain the command that u have written, so that it will be a more helpful.

    Comment by nagesh | 05.4.2011 | 6:39 am

  22. Just copy / paste and worked in 2 seconds on windows 7. Really useful…..

    Comment by Andy | 05.18.2011 | 2:45 pm

  23. It’s really a nice and useful piece of info. I am happy that you just shared this useful info with us. Please stay us informed like this. Thanks for sharing.

    Comment by fat burn | 08.12.2011 | 4:09 am

  24. Great! Worked like a charm.

    Comment by John K | 09.7.2011 | 2:25 pm

  25. On Windows 2008 This worked for me =:
    FOR /F “tokens=*” %G IN (‘DIR /B /AD /S *.svn*’) DO RMDIR /S /Q “%G”

    Comment by Michal | 09.8.2011 | 9:23 am

  26. Excellent piece of work. this helped me a lotttttttttt.. thank you..

    Comment by RK | 10.21.2011 | 1:40 pm

  27. thanks!!!!!!!!

    it helped a lot

    Comment by nilesh | 12.1.2011 | 4:03 pm

  28. Thank you a lot for your sharing this, it saved me time !!!

    Comment by Bob | 04.11.2012 | 11:52 am

  29. Thanks man!
    I was trying to do this on windows using the linux command on cygwin but the damn thing just wont work!

    Ur win command worked like a charm! Thanks!

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

    Comment by kam | 04.16.2012 | 10:09 pm

  30. Worked great.
    Thanks a lot.

    Comment by Baasu | 05.17.2012 | 7:39 am

  31. Thank you so much…

    Comment by Hari | 12.12.2012 | 6:10 am

  32. Recommended Reading…

    Pieter blogt » [SVN] Recursively delete .svn folders…

    Trackback by Recommended Reading | 05.10.2013 | 8:34 pm

 

Leave a comment