'''
@文件 :move.py
@说明 :
@时间 :2022/04/08 18:36:47
@作者 :刘子沫
@邮箱 :spiritai@qq.com
@版本 :1.0
'''
import os,shutil
def copyf(filepath, dst):
if not os.path.exists(dst):
os.makedirs(dst)
shutil.copy(filepath, dst)
def walk(dirname,target):
xml = []
jpg = []
for root, dirs, files in os.walk(dirname):
for filename in files:
fullname = os.path.join(root, filename)
if target in fullname:
xml.append(fullname)
if ".jpg" in fullname:
jpg.append(fullname)
for x in xml:
name = x.split("\\")[-1].replace(".xml","")
for a in jpg:
if name in a:
copyf(x, target+"/labels")
copyf(a, target+"/images")
if __name__ == '__main__':
walk("220218labimg标定数据","四类标注")