文件Move操作

时间:2020-12-20 09:32:23
#coding=utf-8
import os
import shutil
stra = "G:/should/v3/a"
strb = "G:/should/v3/b" fobj = open('D:/V3/bt/c.bt','rb')
line = fobj.readline()
while line:
#print(line)
if(line.find('a') > 0):
line = line.strip('\r\n')
strsha1 = line.split('\\')
strsha1 = strsha1[-1]
if(os.path.exists(line)):
shutil.move(line, stra+'/'+strsha1)
elif(line.find('b') > 0):
line = line.strip('\r\n')
strmd5 = line.split('\\')
strmd5 = strmd5[-1]
if(os.path.exists(line)):
shutil.move(line, strb+'/'+strmd5)
else:
print(line) line = fobj.readline() fobj.close()