Tuesday, July 29, 2008

Recursively delete .svn folders the easy way

you can really use this to delete any given folder that you need to delete recursively, but I needed this today, and google only gives me the answer for linux, and some strange solutions to do the same in windows.

here's a simple solution that works from the command line (the easy way, right?):

for /f "usebackq" %d in (`"dir *.svn /ad/b/s"`) do rd /s/q "%d"

more than anything I know I will need this in the future, so here it is for me, hoping that it can help someone else out there J

8 comments:

Jeremy said...

Not sure of the context in which you are needing to delete .svn folders. But one thing you could do is svn export the project/directory you want to get rid of the .svn files from. This will give you a nice clean project/directory without .svn folders or files.

BlackTigerX said...

I have needed this many times, when you work with multiple branches and are creating copies here and there you need this quite often, (tortoise)svn is not exactly a tool that "just works", I've had many issues using it too

danio said...

I had to do this today after tortoise svn latest build messed up the version of my working copy (the python fixup script couldn't handle it). This slightly more simple command worked for me:

for /R %%i in (.svn) do rd /s/q %%i

danio said...

Should be:
for /R %%i in (.svn) do rd /s/q "%%i"

to handle directory names with spaces in. The for /F way doesn't seem to handle this at all.

Cavemansblog said...

I needed this today and your solution was very effective. Thank you !

Kira said...

Thank you very much!!!!

Snehapriyan said...

Very Useful command. Saved me tons of time. Thanks!

rohit said...

Cool tanx..