import os
import os.path
import shutil
import sys
rootdir = sys.path[0]
for parent, dirnames, filenames in os.walk(rootdir):
for dirname in dirnames:
pathName = os.path.join(parent, dirname)
print(pathName)
if(pathName.endswith('bin') or pathName.endswith('obj')
or "\OutPutPath\logs" in pathName or "\OutPutPath\Data" in pathName):
shutil.rmtree(pathName)
for filename in filenames:
fileName = os.path.join(parent, filename)
if(fileName.endswith(".suo") or fileName.endswith(".pdb") or "\OutPut\BackupPath" in fileName
or "\OutPutPath\Export" in fileName or "\OutPutPath\ExportLog" in fileName
or ".vshost." in fileName):
os.remove(fileName)
Python脚本清理Winform项目下的临时文件及目录
最新推荐文章于 2022-03-25 12:10:24 发布