删除目录下的某些后缀名的文件
2014-11-17 19:29
267 查看
#!/usr/bin/python # -*- coding: utf-8 -*- import os import shutil def move_logs(path,filename): destPath = path + '/../log' if os.path.exists(destPath): shutil.move(os.path.join(path, filename),os.path.join(destPath, filename)) def del_files(path): for root , dirs, files in os.walk(path): for name in files: if name.endswith(".exp") or name.endswith(".ilk") or name.endswith(".lib") or name.endswith(".pdb"): os.remove(os.path.join(root, name)) elif name.endswith(".log"): move_logs(root,name) print ("Delete File: " + os.path.join(root, name)) # test if __name__ == "__main__": path = './' del_files(path) #move_logs(path)
相关文章推荐
- 删除当前目录下所有符合某些patterns的文件
- linux 删除某个目录下的所有某些文件
- python 学习记录(11)-文件处理/读取文件/文件写入内容/文件删除/文件复制/文件重命名/后缀名/内容查找与替换/文件比较/ 配置文件访问/目录创建与删除/遍历目录/定向输出
- 将指定目录下的某些 af8e 相同类型的文件打成zip包存放到指定目录下面并删除原文件
- 批处理_批量删除手机中某些目录中的文件
- 利用python删除指定目录下,指定后缀名文件
- 删除文件和目录(Delphi实现)
- 删除文件目录的Java类
- 删除无限级目录与文件代码共享
- cygwin内子目录及其文件删除不掉,出现access deny错误
- JAVA 如何创建/删除/修改/复制目录及文件
- 如何删除文件夹下所有的文件(包括非空目录和文件)????
- 查找目录下某特定后缀名的文件的简单方法
- 删除指定目录下的所有文件的java类
- DELPHI删除指定目录下指定扩展名的文件
- 删除无限级目录与文件代码共享
- 递归删除一个非空目录及其下所有文件和目录
- 删除某个目录下预定义天数以前的文件的脚本
- 删除无限级目录与文件代码共享
- 源码--删除指定目录下(包含子目录)的文件