首页 > 代码库 > 批量过滤

批量过滤

import  osimport  shutildef 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()