Removing .svn folders from subfolders

In older versions on TortoiseSVN, it would create a version folder called .svn in every sub-folder from the root that was being controlled.  This caused a lot of those folders and the could grow pretty big.

In more recent versions there is only one .svn folder, in the root of the controlled folder.  But those pesky .svn folders are still in all the sub-folders and going through and manually delete them is a pain, to say the least.  

After brushing up on my old DOS and Batch file skills, which I have mostly forgotten, I came up with this - the the help of google.com: 

for /f %i in ('dir /a:d /s /b .svn') do echo rd /s /q %i

This will only SHOW you what is to be deleted, to make it actually delete the folders, remove the echo: 

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

This will now go through each sub-folder and delete the .svn folder.  You can put this into a .bat file for reuse.   

Update, April 28:

While the statements above work, they fail if there are spaces in the sub folder names.  After some research, this is what I found and it seems to work just fine: 

for /f "usebackq delims=" %i in (`dir /a:d /s /b .svn`) do @echo rd /s /q %i

Again, this just dumps the results to the command line window, so you need to remove the echo to make it work:

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

Note that with this version you MUST use grave accent around the text or it will not work.  Hold the Alt key down and enter 96 on the keypad to get it (`)

This will work with long path names with spaces.

 

Arnor Baldvinsson

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk