如果需要複製很多文件,手動肯定是累死人的。
我們可以使用後綴爲.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()