import shutil
shutil.copyfile("E:/test.jpg", "./train/test.jpg")
def get_file_path_by_name(file_dir):
L = []
for root, dirs, files in os.walk(file_dir): # 获取所有文件
for file in files: # 遍历所有文件名
if os.path.splitext(file)[1] == '.jpg': # 指定尾缀 ***重要***
L.append(os.path.join(root, file)) # 拼接处绝对路径并放入列表
shutil.copyfile(os.path.join(root, file), "../mmdetection/mmdetection-master/data/MM2021/testA-images/"+file)
print('总文件数目:', len(L))
return L
list_dir = get_file_path_by_name('./电商标识检测大赛_val_20210409_1')