阅读背景:

Python脚本清理Winform项目下的临时文件及目录

来源:互联网 
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)import os
import os.path
import shutil
im



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: