如果需要复制很多文件,手动肯定是累死人的。
我们可以使用后缀为.bat的批处理文件,双击运行。
自己写一个.bat就好了
import json
with open('long_answer_example_subval.json', 'r') as input:
a = json.load(input)#一个包含文件名字的字典
o = open('cmd.txt','w')#包含命令的输出文件,后期需要把.txt后缀改成.bat
for k, v in a.items():
image_path = v["image_path"]
image_path = image_path.replace('/', '\\')# windows下的路径格式
cmd = 'copy D:\\Work\\content\\ST-VQA\\ST-VQA\\'+image_path+' D:\\Work\\lctog\\best_CAN\\example_pictures\\' + image_path
o.write(cmd)
o.write('\n')
o.write('PAUSE')
o.close()