Home » Development, General » Delete .svn folders recursively

Delete .svn folders recursively

3 December 2008

Very often scenarios crop up when we want to clean our mammoth source code repository without having to export it elsewhere. I was looking for an elegant way to delete hidden .svn folders 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 requirement.

I modified a minor glitch in the command to enable directory deletion from the folders which contain a space in name.

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

Link: http://blog.snakehit.be/2007/08/29/svn-recursively-delete-svn-folders

Bookmark and Share

Development, General

6 Comments to “Delete .svn folders recursively”

  1. So I can just open a DOS/cmd box, cd to the WC dir, and run that command.. It has the same effect as “exporting” a WC right, nice tip!

    Are there any benefits, pros, cons, etc. over using this than just using the normal “export” command? One, I could see that if you wanted to “convert” a WC to a non-WC (like an export), you could run this command in the WC to turn it into non-WC, etc.

  2. You can create a batch file with this command. Put the batch file in the root directory where your repository exist and execute it.
    The benefit of this approach is that you will not have to export your huge source code to some other place and will save huge amount of time. There are scenarios where you want to migrate your existing source code and check in to another empty repository. There can be similar such scenarios where a quick cleanup is the requirement and not the export.

  3. If you want to run this in the command line you will get a %%G was unexpected at this time error. You can fix this by replacing %%G with %G.

  4. Thanks for pointing it out Alec. However, this script was meant for batch file and not to be run as an individual command. :)

  5. This is a good one for deleting the folder structure.

  6. This script helped my precious time a few moments ago. I am trying to create a replica of the repository. There is no documented way of doing so in VisualSVN so I was planning to relocate my existing current working copy to new location and then commit again. Numerous warnings and nags from TortoiseSVN about relocating the existing copy to new repo scared me. Now i will be wiping out all the svn data from my repository and check out the empty repo in the same working copy and safely commit it to create a replica. It was wonderful. Many thanks to you.

Leave a Reply

(required)

(required)