views:

84

answers:

2

I need a batch file that will recursively remove all directories with a certain filename. This is what I have so far and its not working.

FOR /D /r %%G IN ("*.svn") DO DEL %%G

Thanks!

+1  A: 

Wow I recently just did something exactly like this:

edit

FOR /F %%C IN ('dir *.svn /s /b') DO DEL %%~C\*.*

FOR /D %%C IN ('dir *.svn /s /b') DO RMDIR %%~C

You probalby need to pass some parameters to del to allow it to delete without asking yes/no

Alternatively just do svn export to checkout code from the repository without those pesky .svn directories.

Byron Whitlock
this is not working. The folders im trying to delete are named .svn and are hidden.
Jordan
Well you could just do `svn export`. That will export your repository without all the .svn directories.
Byron Whitlock
no that's not an option for me
Jordan
You pretty much got it. Just needed a few tweaks and like you said del needed some params to allow delete. Here's the final command.FOR /F %%C IN ('dir *.svn /s /b /a:d') DO RMDIR %%C /s /q
Jordan
A: 

If you are able to work with Powershell you can use this snippet:

get-childitem . -include .svn -force -recurse | foreach ($_) {remove-item -force $_.fullname}

It's taken from here. Actually if you can use Powershell just forget DOS :)

By the way the dir command has a /s to act recursively (like -r/-R for unix like shells)

Jack