一次性删除 .svn 文件夹
Posted chenjo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一次性删除 .svn 文件夹相关的知识,希望对你有一定的参考价值。
方法一 (Windows 7; Python 3.5.2)
import os
for (p,d,f) in os.walk(r"G:qycache est"):
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 : hclac@sina.com
'''
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
以上是关于一次性删除 .svn 文件夹的主要内容,如果未能解决你的问题,请参考以下文章