import os
import shutil
root = "./data"
dataset ="./data/datasets" #需要分离的文件,即image 与xml在此文件下
img = root + "/JPEGImages"
annotation = root + "/Annotations"
if not os.path.exists(img):
os.mkdir(img)
if not os.path.exists(annotation):
os.mkdir(annotation)
for x in os.scandir(dataset):
if x.name.endswith(".jpg"):
needpath = "./data/datasets/{name}".format(name=x.name)
shutil.move(needpath,img)
if x.name.endswith(".xml"):
needpath ="./data/datasets/{name}".format(name=x.name)
shutil.move(needpath,annotation)
jpg格式与xml格式文件分离到不同的文件夹
最新推荐文章于 2023-11-22 17:51:03 发布