Windows batch file to delete .svn files and folders

纵然是瞬间 提交于 2019-12-02 14:54:56

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`

Edit:

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 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\" \""
Joymaker

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

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.

Here is my favorite, its simple and compact:

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

Fissh

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!