3

Is there a way to delete all subdirectories named .svn from all levels of a directory tree, without touching anything else? rd/s and del/s don't seem to do it.

5 Answers 5

4

for /r /d %i in (.svn) do rd /s /q "%i"

Use %%i instead of %i in batch files, and make sure your current directory is at the top of the hierarchy you want to start from.

Edit: Just noticed that this will also catch folders that end in .svn, not just those that are named .svn.

6

Add the following to a batch file. Do make a backup of the files first.

@for /f "tokens=*" %%a in ('dir /s /b /ad *.svn 2^>NUL') do rd /s /q "%%a"
1
  • Note that if you run this command from Command Prompt then you need to replace the double percent signs with single ones.
    – Wasif
    Sep 20, 2020 at 15:51
3

If your hard disk is NTFS, you can use the free Everything search engine.

After it's installed, right click on the directory and select "Search Everything...".
Then type *.svn to see all such named files and sub-directories.
Click on the first in the list, then type ctrl-A to select the whole list, then type Del to delete them all.

2
  • 2
    Wouldn't this also work with windows' own search function?
    – Console
    Apr 27, 2010 at 20:12
  • @Console: Windows' search is notorious for having hiccups.
    – harrymc
    Apr 28, 2010 at 5:31
3

I see this question asked all the time for users of SVN, you do NOT need a special script to get rid of those pesky .svn folders.

I don't know what platform you are on, but you can use:

 svn export

To make SVN make a copy of your working copy without the .svn folders.

http://www.yolinux.com/TUTORIALS/Subversion.html

http://svnbook.red-bean.com/en/1.0/re10.html

0

You can run powershell one liner:

dir "PATH" -rec|?{($_.psiscontainer)-and($_.name-eq'.svn')}|rm -fo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .