说明:此工具只适用于win32系统,如xp, win7
第一步:下载并安装Python
下载地址:http://www.python.org,下载Python2.7第二步:下载并安装pywin32
下载地址:http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/
下载的是pywin32-218.win32-py2.7.exe第三步:将以下代码保存为delSVN.py文件,然后双击运行,粘贴目录的路径。
import os, platform, sys
WIN32 = 'win32'
SVN = '.svn'
class Util:
@staticmethod
def checkSystem():
system = platform.system()
if system == 'Windows':
return WIN32
@staticmethod
def validatePath(path):
if os.path.isdir(path):
return True
else:
return False
class SVNDeleter:
def __init__(self):
self.ifSuccess = True
def delete_folder(self, path):
for item in os.listdir(path):
itemPath = os.path.join(path,item)
win32api.SetFileAttributes(itemPath, win32con.FILE_ATTRIBUTE_NORMAL)
if os.path.isdir(itemPath):
self.delete_folder(itemPath)
else:
print 'remove', itemPath
try:
os.remove(itemPath)
except:
self.ifSuccess = False
print 'remove', path
try:
os.rmdir(path)
except:
self.ifSuccess = False
def delete_svn_folder(self, tree):
if os.path.isdir(tree):
for item in os.listdir(tree):
itemPath = os.path.join(tree, item)
if os.path.isdir(itemPath):
if item == SVN:
self.delete_folder(itemPath)
else:
self.delete_svn_folder(itemPath)
if __name__ == '__main__':
if Util.checkSystem() != WIN32:
print 'Only supports the win32 os!'
sys.exit()
import win32api, win32con
while(True):
path = raw_input('please input the directory:')
if Util.validatePath(path):
svnDeleter = SVNDeleter()
svnDeleter.delete_svn_folder(path)
if svnDeleter.ifSuccess:
print '\nSuccessful!'
break
else:
print '********************** notice *************************'
print '* Some directory is in use, has not been deleted!!! *'
print '*******************************************************'
else:
print '********************** notice ****************************'
print '\'' + path + '\'', 'is not a valid directory!'
print '**********************************************************'
raw_input()