import  os
import shutil

vpath = "H:/v3/b/"
fobj = open('H:/v3/a.txt','rb')
line = fobj.readline()
while line:
    line = line.strip('\r\n')
    filepath = line.split('\t')[-1]
    filepath = filepath.strip(' ')
    sha1 = filepath.split('\\')[-1]
    foldname = line.split('\t')[0].split('.')[-2]
    newpath = os.path.join(vpath,foldname)
    if(os.path.exists(newpath)):
        if(os.path.exists(filepath)):
            shutil.move(filepath, os.path.join(newpath,sha1))
    else:
        os.makedirs(newpath)
        if(os.path.exists(filepath)):
            shutil.move(filepath, os.path.join(newpath,sha1))
    line = fobj.readline()

fobj.close()

  

posted on 2014-08-27 17:06  小白闯天下  阅读(216)  评论(0编辑  收藏  举报