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