# -*- coding: utf-8 -*-
# @Time : 2021/1/20 17:11
# @Author : hjcui
# @Site :
# @File : delete_little_file.py
# @Software: PyCharm
# @Description: 删除小于600k的文件
import os
dir_path = r'D:\swk_collection'
dir_list = os.listdir(dir_path)
count = 0
for dir in dir_list:
try:
for i in os.listdir(os.path.join(dir_path,dir)):
file = os.path.join(dir_path,dir,i)
if os.path.getsize(file) < 600*1024:
os.remove(file)
except Exception as e:
print(e)
print('删除小文件成功')
用python实现删除指定文件夹下的指定大小的文件
最新推荐文章于 2024-07-17 09:15:39 发布