标签:copy join highlight lis 批量复制 name 重命名 path pre
import os import shutil import time start_time = time.time() # 需要被复制的文件夹 old_path = r‘C:\old_dir‘ new_path = r‘C:\new_dir‘ all_list = os.listdir(old_path) for i in all_list: # print(os.path.join(old_path,i)) for j in os.listdir(os.path.join(old_path,i)): print(j) if j==‘label.png‘: name= i.split(‘_json‘)[0] # name = name.replace(‘.‘,‘‘) old_name = old_path + ‘\\‘ + i + ‘\\‘ + j new_name = new_path + ‘\\‘ + name + ".png" print(new_name) shutil.copyfile(old_name, new_name) # print(len(all_list)) # print(all_list) end_time = time.time() print(end_time-start_time,‘秒‘)
标签:copy join highlight lis 批量复制 name 重命名 path pre
原文地址:https://www.cnblogs.com/xiaoyh/p/13210668.html