Recursively delete .svn folders on Windows
July 21st, 2005
Subversion offers a nice “export” command which will export a clean copy of your project. This is very useful for distributing source code without the .svn folders which are present in the working copy. However, there are times when you will find yourself in front of a deep hierarchy of code which was provided by someone who just zipped up their working copy with all the .svn folders included.
Removing these folders is easy on *nix systems, by doing something like this:
find . -type d -name ‘.svn’ -print0 | xargs -0 rm -rdf
However, this elegant solution is not possible on Windows. So, how do you do it? You could write a quick script (Python, Ruby, etc) or use Ant to perform the task, but if you’re using Total Commander you can do this very easily in a few quick steps:
- Invoke a search (Alt+F7) from the projects root directory
- Search for .svn
- When the results are displayed, click the “Feed to listbox” button (bottom right)
- In the list that appears select all the folders and delete (Shift-F8)
Tags: Subversion, Total Commander






Thanks
Your tip really helped
Comment by SiriuS — December 8th, 2005 @ 10:51 am
For those of you that do not use Total Commander this trick could be accomplished easily in windows explorer as well.
Right click on the folder and click Search..
Enter .svn as the filename to search for.
Click “More advanced options” and select:
- Search hidden files and folders
- Search subfolders
Press search button and delete the folders you find appropriate.
Oh, and this description is at least valid for windows xp pro.
I personally would do a Google search for Cygwin, install it, and use the unix style “find” mentioned above..
Thanks for a great blog..
-Martin
Comment by Martin Henricson — January 3rd, 2006 @ 3:12 pm
Very useful - thanks for the tip
Comment by Christophe — March 22nd, 2006 @ 1:05 pm
Guys, you have got to be kidding. Just perform a standard windows search using windoze explorer for .svn (be sure to include hidden stuff in the search). Then select them all and delete them…
Comment by Wow — September 25th, 2006 @ 9:57 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)
Comment by azizasm — August 16th, 2007 @ 4:15 pm
damn msdos really does suck
Comment by kane — September 20th, 2007 @ 8:20 pm
[…] http://www.broobles.com/blog/posts/36 […]
Pingback by Delete All .svn Files in windows | Axelology — March 11th, 2008 @ 6:45 pm
With TortoiseSVN you can export a locally versioned folder into itself, and the .svn files will be removed like that.
However, not everybody on Windows uses TortoiseSVN as the SVN client (there are lots of SVN clients for Windows), and it appears that the export function of TortoiseSVN will only work if your locally versioned folder has been managed by TortoiseSVN from the start.
Comment by jack — January 12th, 2009 @ 9:46 am
@Wow - Yes of course you can do a search like that … there’s nothing wrong with it at all, but going through the GUI for every task you need to do is awkward and you’d have manually do it every time.
You might save only a few seconds, but professional developers need to get into the habit of automating tasks as much as possible to save as much time as possible (just think when you need to accomplish hundreds of tasks a day)
Comment by jack — January 12th, 2009 @ 9:50 am
beautifullll
Comment by fred — February 26th, 2009 @ 4:31 pm