单张图片
import os
ori = "/home1/zy/dataset/cheshi"
target = "/home1/zy/dataset/cheshi2/"
def get_fileNames(rootdir,target):
#如果有目标文件夹就不管,没有就自己创建
if not os.path.exists(target):
os.makedirs(target)
for root, dirs, files in os.walk(rootdir,topdown = True):
for name in files:
_, ending = os.path.splitext(name)
if ending == ".jpg":
shutil.copyfile(os.path.join(root,name), target+name)
get_fileNames(ori,target)