[SVN] Recursively delete .svn folders
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"
Thank you! Saved me alot of effort
Comment by Simon Cruise | 06.28.2008 | 11:43 am
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
very nice tip to DELETE .SVN FOLDERS in WINDOWS
Comment by Sameer | 09.12.2008 | 8:46 pm
[...] 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
TERRIFIC!!!! THANKS
Comment by DHIRAJ | 01.5.2009 | 9:15 am
worked great. Thanks.
Comment by chad caldwell | 02.13.2009 | 8:34 pm
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
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
[...] 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
Thank you! Works great.
Comment by Cimi | 11.10.2009 | 11:42 pm
Thanks, worked for me!!!
Comment by Timi | 12.18.2009 | 7:53 pm
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
amazing stuff thanx
rH3uYcBX
Comment by SantaBlue | 12.29.2009 | 7:27 pm
[...] 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
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
thanks!
Comment by ds | 08.13.2010 | 12:01 pm
Thank you very much. this works good.
Comment by Nagarajulu | 09.2.2010 | 1:00 pm
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
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
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
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
Just copy / paste and worked in 2 seconds on windows 7. Really useful…..
Comment by Andy | 05.18.2011 | 2:45 pm
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
Great! Worked like a charm.
Comment by John K | 09.7.2011 | 2:25 pm
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
Excellent piece of work. this helped me a lotttttttttt.. thank you..
Comment by RK | 10.21.2011 | 1:40 pm
thanks!!!!!!!!
it helped a lot
Comment by nilesh | 12.1.2011 | 4:03 pm
Thank you a lot for your sharing this, it saved me time !!!
Comment by Bob | 04.11.2012 | 11:52 am
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
Worked great.
Thanks a lot.
Comment by Baasu | 05.17.2012 | 7:39 am
Thank you so much…
Comment by Hari | 12.12.2012 | 6:10 am
Recommended Reading…
Pieter blogt » [SVN] Recursively delete .svn folders…
Trackback by Recommended Reading | 05.10.2013 | 8:34 pm