Command to recursively remove all .svn directories on Windows

后端 未结 8 1093
死守一世寂寞
死守一世寂寞 2020-12-07 08:12

I have a directory with many sub-directories. In each folder there is a subversion folder (.svn).

Is there a command in windows that will go through each folder and

相关标签:
8条回答
  • 2020-12-07 08:19

    As an important point, if you want to run shell to delete .svn folders, you may need -depth argument to prevent find command entering the directory that was just deleted and showing silly error messages like e.g.

    "find: ./.svn: No such file or directory"
    

    To get rid of this error, you can use the find command as the following:

    cd [dir_to_delete_svn_folders]
    find . -depth -name .svn -exec rm -fr {} \;
    
    0 讨论(0)
  • 2020-12-07 08:21

    Make a litte batch file with the following line and execute it from the parent folder under which there are .svn directories.

    FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G"
    

    You can also issue the line below straight from the Command Prompt:

    FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%G"
    
    0 讨论(0)
  • 2020-12-07 08:21

    I know its too late to answer this but i guess there is an easy way IF have eclipse and the svn plugin installed on your eclipse. 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 .svn folders only!

    0 讨论(0)
  • 2020-12-07 08:25

    Just type .svn in the search box of the File Explorer, then select and delete all search results (see JB Nizet's comment). This method can of course also be used to quickly delete the obj and bin directories, e.g. when organizing svn archives.

    Although OP asked for a commandline solution, he also indicated using Windows, and considered a manual deletion, so the File Explorer method could still be considered, especially because it is the fastest method and does not rely on 'tools' like svn export.

    Although OP already selected an accepted answer, this answer might still be useful for others. At least it was useful for me, a long time linux / windows user who prefers command lines and first learned about the search box by this post :-)

    0 讨论(0)
  • 2020-12-07 08:31

    Use the svn export command to export a Subversion working copy into a new "clean" directory structure that doesn't have the .svn directories.

    0 讨论(0)
  • 2020-12-07 08:37

    Do this in PowerShell.

    NOTE: This is recursive so be sure you are in the right directory!

    gci -fil '.svn' -r -force | ri -r -force
    

    Here is the rest of my source tree cleanup script.

    gci -fil 'bin' -r -force | ri -r -force
    gci -fil 'obj' -r -force | ri -r -force
    gci -fil '_ReSharper*' -r -force | ri -r -force
    gci -fil '*.suo' -r -force | ri -r -force
    gci -fil '*.user' -r -force | ri -r -force
    
    0 讨论(0)
提交回复
热议问题