一次性删除 .svn 文件夹
方法一 (Windows 7; Python 3.5.2)
import os for (p,d,f) in os.walk(r"G:\qycache\test"): if p.find('.svn')>0: os.popen('rd /s /q %s'%p)
方法二(Windows 7; Python 3.5.2)
#! /windows ''' File : CodeLine.py Author : HCLAC E-Mail : ''' import os,sys import stat absolutPath = os.getcwd() def DeleteSvnDir(delDirName): if os.path.isfile(delDirName): try : #print (delDirName) os.chmod(delDirName, stat.S_IWRITE ) os.remove(delDirName) except: pass elif os.path.isdir(delDirName): for item in os.listdir(delDirName): itemsrc = os.path.join(delDirName, item) DeleteSvnDir(itemsrc) try: os.rmdir(delDirName) #print (delDirName) except: #print (delDirName) pass def FindSvnDir(OrginPath): for root, dirs, fileNames in os.walk(OrginPath): for dirName in dirs: if dirName == ".svn": delDirNameTemp = os.path.join(absolutPath, root) delDirName = os.path.join(delDirNameTemp, dirName) #print (delDirName) DeleteSvnDir(delDirName) #else : #FindSvnDir(dirName) #main FindSvnDir(absolutPath)
方法三(Windows 7; cmd.exe)
@echo On @Rem delete .svn folders @Rem PROMPT [Com] @for /r . %%a in (.) do @if exist "%%a/.svn" rd /s /q "%%a/.svn" @Rem for /r . %%a in (.) do @if exist "%%a/.svn" @echo "%%a/.svn" @echo Mission Completed. @pause
参考资料:
https://blog.csdn.net/weixin_34019929/article/details/93316753
https://blog.csdn.net/aa779025105/article/details/50791227
https://blog.csdn.net/zltAlma/article/details/88739022