Recursively Delete Subversion Folders
May 13th, 2007
I’ve been doing a spot of work that requires version control, so we’ve been using Subversion. It’s great, but if you’re anal like me then you may not like the .svn files that litter your working directories after you’re finished. Rather than doing a full SVN export, I cobbled together a VB script to delete them all in one fell swoop. Might help someone else on a random Google search. so posting it here. Sorry for being boring.
OPTION EXPLICIT
Dim FSO, Folder, SubFolder, LogFile, DeletedCount
DeletedCount = 0
If MsgBox ("This will delete ALL of your subversion folders for this repository. Are you sure?", vbYesNo) = vbYes Then
Set FSO = CreateObject("Scripting.FileSystemObject")
Set LogFile = FSO.CreateTextFile("./svn-cleanup.txt")
DoSvnDelete ("./")
MsgBox(DeletedCount & " .svn file(s) were deleted. See log file for rundown.")
Set FSO = Nothing
End If
Sub DoSVNDelete (Path)
If FSO.FolderExists (Path) Then
Set Folder = FSO.GetFolder(Path)
If Folder.SubFolders.Count > 0 Then
For Each SubFolder In Folder.SubFolders
If SubFolder.Name = ".svn" Then
LogFile.WriteLine ("Deleted: " & Path & "\" & SubFolder.Name)
SubFolder.Delete
DeletedCount = DeletedCount + 1
Else
DoSVNDelete (SubFolder)
End If
Next
End If
End If
End Sub
May 13th, 2007 at 9:59 pm
worst post EVER!
May 15th, 2007 at 8:33 am
what has happened to this blog?
May 15th, 2007 at 9:11 am
Sorry
Glad it got the title of worst post ever, though. Quite an accolade!
I’ll try better next time.
I rate this post an F-
FAIL
May 18th, 2007 at 11:09 am
aaaaaaaghhhhhhhhhhhhhh
my boyfriend is a geek….i just noticed….
May 18th, 2007 at 12:06 pm
Yeah, well it could be worse. At least I’m not into physics and stuff.
May 24th, 2007 at 5:03 pm
” Dave Says:
May 18th, 2007 at 12:06 pm
Yeah, well it could be worse. At least I’m not into physics and stuff.”
Does Necrophilia and Animal Fettling come under “stuff”? ‘cos you’re well into that!
May 24th, 2007 at 5:05 pm
You know, this was such a bad post, that when my mum walked into the room and asked her what I was looking at, I couldn’t tell her the truth so I said, “Hardcore Porn”
May 24th, 2007 at 9:19 pm
I thought I saw your name on a loaf of bread…. you know the deal
June 3rd, 2007 at 4:31 am
Dear Mr Dave,
I was perusing google for such a help, those pesky sfv files infiltrate all my directories, sometimes with disasterous consequences, one of them even crept out of my usb port thru my USB cup warmer and spoiled my coffee the little rascal, thankyou for taking the time to help another fellow coder delete the sneaky bastards en-masse, now if only I could write a program to delete all my .exe files in one go that crazy windows program might not act up so much.
thanks again
Geeky T Geekerton, geeksville!
June 3rd, 2007 at 4:33 am
did I say sfv files, damn it!!!
June 3rd, 2007 at 10:56 am
Cheeky sod.
June 3rd, 2007 at 10:59 am
…and Lee, post something or some photos damn it!
August 16th, 2007 at 4:18 pm
The easiest way is by creating a .cmd script file at the root directory and execute it. Here is the code for cleanSVN.cmd :
for /f “tokens=* delims=” %%i in (‘dir /s /b /a:d *svn’) do (
rd /s /q “%%i”
)
regards,
azizasm (Malaysia)