Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows batch file to delete .svn files and folders

Tags:

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 exactly ".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.

like image 956
Marco Demaio Avatar asked Mar 28 '10 11:03

Marco Demaio


People also ask

How do I delete a .SVN file in Windows?

Right click on the project, go to Team->disconnect. It will open a popup where you select the first option: 'Also delete the SVN meta-information from file system. ' This will remove all the SVN folders automatically along with svn property files that you might forget sometimes while removing .

How do I delete a .SVN folder?

To remove a file from a Subversion repository, change to the directory with its working copy and run the following command: svn delete file… Similarly, to remove a directory and all files that are in it, type: svn delete directory…

How do I delete a .SVN folder recursively?

The find command returns a list of all the subfolders matching “. svn”, and this is then piped to the rm command to recursively delete the directory. Running rm using the full path will remove the confirmation prompt, and the “rf” arguments will recursively delete any folder contents.


1 Answers

you can try

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul) 
like image 109
ghostdog74 Avatar answered Sep 19 '22 14:09

ghostdog74