- 论坛徽章:
- 1
|
本帖最后由 jackson_cu 于 2015-04-02 13:26 编辑
试着做了一个...
- import os
- sep = os.path.sep
- extsep = os.path.extsep
- def RemoveCompressFiles(dstFolder):
- for roots,paths,files in os.walk(dstFolder):
- if len(files) > 0:
- #print roots,paths
- if len(paths)!=0:
- for subpaths in paths:
- #print subpaths
- for subfiles in files:
- file_name = os.path.splitext(subfiles)
- file_prefix = file_name[0]
- file_ext = file_name[1]
- #print file_prefix,file_ext
- if file_ext in ['.zip','.rar','.7z','.log']:
- if subpaths == file_prefix:
- zipfile=os.path.join(roots,subfiles)
- file_size = os.path.getsize(zipfile)/1024/1024
- print zipfile,">",file_size,"MB"
- if __name__ == '__main__':
- RemoveCompressFiles('c:\intel\logs')
复制代码 |
|