分类目录归档:小工具

写了个 py来删除 解压缩后漫画和文件夹~~

唔,因为呢,有时候很多东西解压出来之后除错了,导致文件名被创建了但是大小却为0…于是写了个py把他们统统删掉!

 

import string, os, shutil

dir='D:\\MyDocs\\2nd\\Comic\\'

fout=open('list.txt',"w")
tot = 0

for root, dirs, files in os.walk(dir):
    for name in files:
        src=os.path.join(root, name)
        try:
            a = os.path.getsize(src)
            if a == 0L:
                print src+'Removed'
                os.remove(src)
        except:
            print 'ERR! at'+src

    L = os.listdir(root)
    if len(L) == 0:
        os.rmdir(root)