Lo siguiente es copiar el archivo json en la carpeta de la carpeta 0 a otro directorio de archivos json 0. Hay varios archivos json a continuación que se pueden cambiar, en el código.
import os
import shutil
path = r'C:\Users\Administrator\Desktop\project\fire_dataset_7_0\0'
new_path = r'C:\Users\Administrator\Desktop\project\fire_dataset_7_0\0_json'
filelist = os.listdir(path)
i = 1
for item in filelist:
if item.endswith('json') or item.endswith('json') or item.endswith('json') or item.endswith('json'):
src = os.path.join(os.path.abspath(path), item)
dst = os.path.join(os.path.abspath(new_path),item)
# new_name = os.path.join(os.path.abspath(new_path),''+str(i)+'.bmp')
new_name = os.path.join(os.path.abspath(new_path), '' + str(i)+'.json')
#复制图像
shutil.copy(src,dst)
#重命名---把下面两行注释了就不会更改图片的名字。。。
os.rename(dst, new_name)
i += 1
print(src)
print(new_name)