views:

3044

answers:

6

I want to delete every "_svn" in every folder and subfolder...

For example

c:\
  proyect1
   _svn
   images
     _svn
     banner
       _svn
     buttons
       _svn

Then I run something like

rm-recurse c:\proyect1 _svn

And I should get:

c:\
  proyect1
   images
     banner
     buttons

The ideal thing would be a tiny stand-alone EXE or something like that.

-- Thanks Grant, as soon as I posted the question I saw SVN documentation about the SVN export command, but I also want to delete the _vti_* folders stuff Visual Studio creates, so I'll also explore the for solution.

+8  A: 

for /f "usebackq" %d in ("dir _svn /ad/b/s") do rd /s/q "%d"

http://ebersys.blogspot.com/2008/07/recursively-delete-svn-folders-easy-way.html

BlackTigerX
I get an error: couldn't find dir file, I tried with cmd.exe /c dir ..., but i get the same error, however, JMD's solution dis the trick...
opensas
Oops, I checked the page you linked to, seems like there where a couple of ´´ (single quotes) missing... fixing that also did the trick...
opensas
+5  A: 

In Windows? If you are using tortoiseSVN you can use the export command to export a copy of the project without the .svn/_svn folders.

Grant
You can also do svn export with the command line tool whether you are on Windows or not.
Parappa
+10  A: 

Similar to BlackTigerX's "for", I was going to suggest

for /d /r . %d in (_svn) do @if exist "%d" rd /s/q "%d"

JMD
is the "if exist" required?
BlackTigerX
Yes, because the nature of this "for" is that it adds "_svn" to every directory entry as it recurses the directory tree.
JMD
Your solution bypasses that by returning an explicit list of the existing directories.
JMD
A: 

Here... with FreeCommander or TotalCommander

http://www.broobles.com/blog/posts/36

socendani

As a long time TotalCommander (formerly Windows Commander!) user, I can't let this answer stay negative. This is a great, simple solution for someone who already has TC installed. I'm glad to have learned this nifty trick. Thanks!
Adam Tuttle
+1  A: 
import os
import shutil

curdir = os.path.abspath(os.path.dirname(__file__))

def removedir(dirname, name = ".svn"):
    if os.path.isdir(dirname):
        for file in os.listdir(dirname):
            if os.path.isdir(os.path.join(dirname, file)) and file == name:
                thedir = os.path.join(dirname, name)
                shutil.rmtree(thedir)
                print ".",
            else:
                removedir(os.path.join(dirname, file))

I think you can try this Python script, which will work under any OS if you've got Python installed.

Tower Joo
+2  A: 

Time to learn some PowerShell ;o)

Get-ChildItem -path c:\projet -Include '_svn' -Recurse -force | Remove-Item -force -Recurse

The first part finds each _svn folder recursively. Force is used to find hidden folders. Second part is used to delete these folders and their contents. Remove commandlet comes with a handy "whatif" parameter which allows to preview what will be done.

PowerShell is available for Windows XP and Windows Vista. It is present on Windows 7 and on Windows Server 2008 R2 by default.

It's a MS product, it's free, and it rocks!

Cédric Rup