这不是一个问题:Rename script with [Errno2] No such file or directory
我试图根据列文件夹和测试文件夹中相应的xml文件名将图像从文件夹图像移动到train_images和test_images文件夹。但是一致地得到这个错误:Traceback (most recent call last): File "Move2.py", line 13, in <module> os.rename(src2,dest2) FileNotFoundError: [Errno 2] No such file or directory: '/home/mohit/darkflow/yes/images/DSCN8434.jpg' -> '/home/mohit/darkflow/yes/train_images/DSCN8434.jpg'
我的剧本是:
import os
train=os.listdir("/home/mohit/darkflow/yes/train")
test=os.listdir("/home/mohit/darkflow/yes/test")
path2="/home/mohit/darkflow/yes/images/"
moveto3="/home/mohit/darkflow/yes/train_images/"
moveto4="/home/mohit/darkflow/yes/test_images/"
for f_name in train:
f_name=f_name.replace(".xml",".jpg")
src2=path2+f_name
dest2=moveto3+f_name
os.rename(src2,dest2)
for f_name2 in test:
f_name2=f_name2.replace(".xml",".jpg")
src2=path2+f_name2
dest=moveto4+f_name2
os.rename(src2,dest2)提前谢谢!
发布于 2018-11-04 13:20:02
我发现了错误。
解决方案:
代码确实起作用了
谢谢!
https://stackoverflow.com/questions/53140840
复制相似问题