Windows batch file to delete .svn files and folders
- by Marco Demaio
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!