views:

494

answers:

2

Hi,in order to delete all ".svn" files/folders/subfolders in "myfolder" I use this simple line in a batch file:

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X")

This works, but if there are no ".svn" files/folders the batch file shows a warning saying: "The system cannot find the file specified." This warning is very noisy so I was wondering how to make it understand that if it doesn't find any ".svn" files/folders he must skip the RD command.

Usually using wild cards would suffice, but in this case I don't know how to use them, because I don't want to delete files/folders with .svn extension, but I want to delete the files/folders named exactly ".svn", so if I do this:

FOR /R myfolder %%X IN (*.svn) DO (RD /S /Q "%%X")

it would NOT delete files/folders named extaclty ".svn" anymore. I tried also this:

FOR /R myfolder %%X IN (.sv*) DO (RD /S /Q "%%X")

but it doesn't work either, he deletes nothing.

Thanks for any help!

+3  A: 

you can try

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)
ghostdog74
Works great! Thanks!
Marco Demajo
A: 

Something like that using find :

rm -rf `find . -name ".svn" -type d`
Niklaos
er... *Windows* batch file?
nickf
sry i read bash ^^. Whatever, this will help linux users :p
Niklaos
@nickf: what's wrong with "Windows batch file"? I mean a file with .BAT extension.
Marco Demajo
@Marco, there's nothing wrong with what you said. Niklaos just gave a unix based answer, that's all.
nickf