Windows batch file to delete .svn files and folders

前端 未结 8 1376
一生所求
一生所求 2021-01-30 09:16

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         


        
相关标签:
8条回答
  • 2021-01-30 09:57
    for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (rd /s /q "%%i")
    
    0 讨论(0)
  • 2021-01-30 09:57

    Here is my favorite, its simple and compact:

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

    Fissh

    0 讨论(0)
  • 2021-01-30 09:58

    Actually, this answer is from Jesper Rønn-Jensen at http://justaddwater.dk/2011/03/01/easy-delete-all-svn-subfolders-in-windows-explorer/

    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.

    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 http://www.iamatechie.com/remove-all-svn-folders-in-windows-xp-vista/
    ;
    ; Enrichened with comments by Jesper Rønn-Jensen ( http://justaddwater.dk/ )
    ;
    ;
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
    @="Delete SVN Folders"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
    @="cmd.exe /c \"TITLE Removing SVN Folders in %1 && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""
    
    0 讨论(0)
  • 2021-01-30 10:00

    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

    0 讨论(0)
  • 2021-01-30 10:03

    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.

    Ken

    0 讨论(0)
  • 2021-01-30 10:03

    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 http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/

    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.

    0 讨论(0)
提交回复
热议问题