VC编译后生成的Debug、Release、ipch目录及sdf文件占用大量空间,不方便代码保存,写了个Python程序自动遍历清理。
import osimport shutildef remove_vc_extra(root_dir): list_dirs = os.walk(root_dir, topdown=False) for dirpath, dirnames, filenames in list_dirs: for dirname in dirnames: if dirname == 'Debug' or dirname == 'Release' or dirname == 'ipch': shutil.rmtree(os.path.join(dirpath, dirname), ignore_errors=True) for filename in filenames: path, ext = os.path.splitext(filename) if ext == '.sdf': os.remove(os.path.join(dirpath, filename))if __name__ == '__main__': root_dir = input('根目录:') remove_vc_extra(root_dir)
原文地址:Python遍历清理VC项目中的Debug Release ipch 及 sdf, 感谢原作者分享。 思念是一种幸福的忧伤,是一种甜蜜的惆怅,是一种温馨的痛苦;