标签:box 清理 out cep imp int rom debug walk
import shutil
import stat
from tkinter import messagebox
from tkinter.filedialog import *
if __name__ == '__main__':
try:
strDirPath = askdirectory() # 1,选择目标文件夹路径
if len(strDirPath):
listExtension = ['.DB']
listDir = ['DEBUG', 'RELEASE', 'X64', 'IPCH', 'OUT']
for r, ds, fs in os.walk(strDirPath): # 2,遍历文件文件夹
for i in fs:
n, e = os.path.splitext(i) # 前缀.后缀 -> (前缀,.后缀)
if e.upper() in listExtension: # 3.1,删除匹配后缀的目标文件
os.chmod(os.path.join(r, i), stat.S_IWRITE) # 剔除只读属性
os.remove(os.path.join(r, i))
for i in ds:
if i.upper() in listDir: # 3.2,删除名称匹配的目标文件夹
shutil.rmtree(os.path.join(r, i))
messagebox.showinfo('清理工程', '完成')
except Exception as e:
print(e)
标签:box 清理 out cep imp int rom debug walk
原文地址:https://www.cnblogs.com/dailycode/p/12151469.html