python实现移动指定名字的文件夹

import os
import shutil
i= 0
f1 = open("/home/david/workspace/bags/loudao_rgbd/KeyFrameTrajectory.txt", "r")
while True:
    i = i + 1
    line1 = f1.readline()
    if line1:
        filename1 = line1.split(" ")
        print filename1[0]    # do something here
        f2 = open("/home/david/workspace/bags/loudao_rgbd/loudao.txt", "r")
        for line2 in f2:
            filename2 = line2.split(" ")  # do something here
            if filename1[0] == filename2[0]:
                shutil.copy("/home/david/workspace/bags/loudao_rgbd/rgb/"+filename1[0]+".png",
                            "/home/david/workspace/bags/loudao_rgbd/rgb_1/"+str(i)+".png")
                shutil.copy("/home/david/workspace/bags/loudao_rgbd/depth/" + filename2[2] + ".png",
                            "/home/david/workspace/bags/loudao_rgbd/depth_1/" + str(i) + ".png")
        f2.close()


    else:
        break

f1.close()

猜你喜欢

转载自blog.csdn.net/yinxingtianxia/article/details/80267033