#!/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)