删除小于2k的文件,代码如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/1/10 15:34
# @Author : zxb
import os def file_path(path):
for (root, dirs, files) in os.walk(path):
for dirc in dirs:
if dirc == 'pic_neg':
pic_path = os.path.join(root, dirc)
for file in os.listdir(pic_path):
file = pic_path + '/' + file
print(file)
del_small_file(file) def del_small_file(file_name):
size = os.path.getsize(file_name)
file_size = 2*1024
if size < file_size:
print('remove',size,file_name)
os.remove(file_name) if __name__ == '__main__':
path = r'F:\test'
file_path(path)
# file_name = r'F:\test\05.jpg'
# del_small_file(file_name)

最新文章

  1. JSP多文件上传到服务器
  2. SQL用先进先出存储过程求出库数量
  3. vm虚拟机安装雨林木风ghost镜像
  4. NIO源码阅读
  5. BackgroundCheck – 根据图片亮度智能切换元素样式
  6. IE6/IE7中display:inline-block解决办法
  7. bzoj3521: [Poi2014]Salad Bar
  8. CRC校验代码实现
  9. Ubuntu VPN连接设置
  10. ubuntu common
  11. CentOS6.5下Mysql数据库的安装与配置
  12. sql 行转列 PIVOT 列转行 UNPIVOT
  13. Java IO 嵌套流、文本的输入输出和存储
  14. 网易云音乐mp3外链、真实地址下载方法
  15. 斯坦福深度学习与nlp第四讲词窗口分类和神经网络
  16. python 写文件刷新缓存
  17. 转 JavaScript中判断对象类型的种种方法
  18. IE低版本浏览器兼容问题
  19. 阿里云提示ECS服务器存在漏洞处理方法
  20. [POI2017]Sabotaż

热门文章

  1. 每日命令:(13)more
  2. buf.values()
  3. POJ1222熄灯问题【位运算+枚举】
  4. 关于SQL Server 的限制
  5. 【20】AngularJS&#160;参考手册
  6. 【bzoj3505】[Cqoi2014]数三角形
  7. [NOIP2007] 提高组 洛谷P1098 字符串的展开
  8. mysql 之 Workbench的使用
  9. CSS font-family 属性
  10. hdu - 1150 Machine Schedule (二分图匹配最小点覆盖)