# 导入对路径 *** 作的库 import sys import os from IPython import embed import shutil import glob import os, random, shutil def makesDir(filepath): #判断如果文件不存在,则创建 if not os.path.exists(filepath): os.makedirs(filepath) def moveFile_q(fileDir, tarDir): pathDir = os.listdir(fileDir) # 取图片的原始路径 for name in pathDir: shutil.copy(os.path.join(fileDir,name) , os.path.join(tarDir,name)) if __name__ == '__main__': gallery_path = '/home/jy/xl/workstation/Datasets/Car/Nighttime_Vehicle_ReID/gallery' # 设置创建后文件夹存放的位置 test_temp_path = '/home/jy/xl/workstation/Datasets/Car/Nighttime_Vehicle_ReID/Gallery' #根目录,下面有很多子文件夹 makesDir(gallery_path) img_names = os.listdir(test_temp_path) for img_name in img_names: img_name_path = os.path.join(test_temp_path,img_name) moveFile_q(img_name_path, gallery_path)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)