码迷,mamicode.com
首页 > 其他好文 > 详细

批量过滤

时间:2014-08-12 16:35:04      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:blog   os   div   line   log   python   ad   ef   

import  os
import  shutil


def ProcessStr(path, flag):
    line = path.strip(‘\n‘)
    line = line.split()
    fullpath = line[0]
    fullpath = fullpath[:49]
    sha1 = fullpath[13:49]

    if os.path.exists(fullpath):
        pass
    else:
        return

    if(1 == flag):
        shutil.move(fullpath, os.path.join(‘f:\\s1\\‘,sha1))
    elif(2 == flag):
        shutil.move(fullpath, os.path.join(‘f:\\s2\\‘,sha1))
    elif(3 == flag):
        shutil.move(fullpath, os.path.join(‘f:\\s3\\‘,sha1))
    elif(4 == flag):
        shutil.move(fullpath, os.path.join(‘f:\\s4\\‘,sha1))
    elif(5 == flag):
        shutil.move(fullpath, os.path.join(‘f:\\s5\\‘,sha1))
    elif(6 == flag):
        shutil.move(fullpath, os.path.join(‘f:\\s6\\‘,sha1))





def MoveF():
    fobj = open(‘d:\\tmp.txt‘,‘r‘)
    line = fobj.readline()
    while line:
        line = line.strip(‘\n‘)
        if(line.find(‘a‘) != -1):
            ProcessStr(line,1)
        elif(line.find(‘b‘) != -1):
            ProcessStr(line,1)
        elif(line.find(‘c‘) != -1):
            ProcessStr(line,1)
        elif(line.find(‘d‘) != -1):
            ProcessStr(line,1)
        elif(line.find(‘e‘) != -1):
            ProcessStr(line,2)
        elif(line.find(‘f‘) != -1):
            ProcessStr(line,3)
        elif(line.find(‘g‘) != -1):
            ProcessStr(line,4)
        elif(line.find(‘h‘) != -1):
            ProcessStr(line,5)
        elif(line.find(‘i‘) != -1):
            ProcessStr(line,5)
        elif(line.find(‘j‘) != -1):
            ProcessStr(line,6)
        elif(line.find(‘k‘) != -1):
            ProcessStr(line,6)
        else:
            print(line)
        line = fobj.readline()
    fobj.close()



if __name__ == "__main__":
    MoveF()

  

批量过滤,布布扣,bubuko.com

批量过滤

标签:blog   os   div   line   log   python   ad   ef   

原文地址:http://www.cnblogs.com/xiaobaichuangtianxia/p/3907193.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!