aw1039-Md5DiRemove.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "月影鹏鹏"
__date__ ="$2011-2-16 17:39:40$"

'''
QQ:1356281767
email: jk@aiwaly.com
web: http://www.aiwaly.com

'''
import os,time ,sys ,shutil
#获得文件后缀                
def file_extension(path):
    return os.path.splitext(path)[1]


#文件下载hash目录存储#aiwaly-pymo-0009-wget_file_hash
def remout_file_hash( filename):   
        import sys ,os 
        ##判断临时目录是否存在
        hashdir=filename.split(".MD5-")[1]
        subjectpah=path + "/" +hashdir[0] + hashdir[1] + "/"+hashdir[1] + hashdir[2] + "/"
        print(subjectpah)        
        if not os.path.isdir(subjectpah):
                 os.makedirs(subjectpah)

        shutil.move(filename  ,subjectpah + os.path.basename(filename))

def file_path(path):
    for fpathe,dirs,fs in os.walk(path):
           for f in fs :
                 print( os.path.join(fpathe,f))
                 extension_name =file_extension (os.path.join(fpathe,f))

                 if  extension_name.lower()  == ".egz" :
                     remout_file_hash(os.path.join(fpathe,f)) 
                     #time.sleep(1)                     


#print(os.path.basename(os.path.realpath(__file__)))
#path=sys.argv[1]
path="d:/tmp/mgz_path"
print(path)

file_path(path)
文档更新时间: 2019-06-14 13:38   作者:月影鹏鹏