import os
from os import listdir, getcwd
from os.path import join
import shutil
in_path = r"D:\wjy\train_12_classes\datas\Illegal_umbrella\video_image"
out_pic_Path = r"D:\wjy\train_12_classes\datas\Illegal_umbrella\data1\pic"
out_xml_path = r"D:\wjy\train_12_classes\datas\Illegal_umbrella\data1\label"
def get_files(inPath,out_pic_Path,out_xml_path):
for filepath,dirnames,filenames in os.walk(inPath):
for filename in filenames:
str1 = filename.split('.')[0]
str1_1 = filename.split('.')[1]
if str1_1 == "xml":
shutil.copy(filepath + "\\" + filename, out_xml_path)
elif str1_1 == "jpg" or str1_1 == "jpeg" or str1_1 == "JPG" or str1_1 == "JPEG":
shutil.copy(filepath + "\\" + filename, out_pic_Path)
else:
continue
get_files(in_path,out_pic_Path,out_xml_path)