Windows batch file to delete .svn files and folders

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.

  • What is the difference in command line argument syntax between bat and sh?
  • Git rebase non-interactive for last two commits - write a batch file
  • Jenkins and return code from windows batch
  • How to input password to git pull command?
  • Out of a git console: how do I execute a batch file and then return to git console?
  • “'git' is not recognized as an internal” blah blah even though the command works the first time
  • 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.

  • How to get SVN revision in Gradle for Android?
  • Best practice to manage source code with multiple skins in Xcode
  • An SVN error (200 OK) when checking out from my online repository
  • Deployment practices for .NET
  • Re-apply a previously reverted commit in SVN
  • Which files in a Visual C# Studio project don't need to be versioned?
  • 8 Solutions collect form web for “Windows batch file to delete .svn files and folders”

    you can try

    FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)
    for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (rd /s /q "%%i")

    Something like that using find :

    rm -rf `find . -name ".svn" -type d`


    I know this is for linux (I read bash instead of batch). I’m leaving it here to help Linux users that would randomly end-up here 🙂

    Actually, this answer is from Jesper Rønn-Jensen at

    I thought it was so much easier I’d share. I’m converting several projects from .SVN to .GIT, so this was great. It adds a menu item to Explorer so you can remove the folders. Create a .reg file, and import it.

    enter image description here

    Windows Registry Editor Version 5.00
    ; Running this file will give you an extra context menu item in Windows Explorer
    ; "Delete SVN folders"
    ; For the selected folder, it will remove all subfolders named ".svn" and their content
    ; Tip from
    ; Enrichened with comments by Jesper Rønn-Jensen ( )
    @="Delete SVN Folders"
    @="cmd.exe /c \"TITLE Removing SVN Folders in %1 && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

    Bizarre sidenote: if I use

    FOR /R . %%X IN (*.svn) DO (echo "%%X")

    instead of

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

    not only does it list all directories ending in .svn, it lists ALL THEIR CONTENTS as well. This is a BUG in the For command, it gave me an expansion where I gave it no wild card. Very strange.


    If you want to delete all sub folders named .svn in Windows
    then create batch file with this content:

    for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (
    rd /s /q "%%i"

    save it in a file del_All_Dot_SVN_Folders.cmd . Run it. Your done.

    Thanks to

    Remember the above code has .svn whereas the code in the link has only *svn so its better
    to have the .svn to not accidentally have undesired effect.

    Here is my favorite, its simple and compact:

    find ./ -name ".svn" | xargs rm -Rf


    To delete all svn files on windows

    for /d /r . %d in (.svn) do @if exist "%d" rd /s/q "%d"

    .svn is the folder name

    Git Baby is a git and github fan, let's start git clone.