首页 > 代码库 > 批量过滤
批量过滤
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()
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。