import os
rootimgs = 'D:\dataset\cityscapes\cityscape_voc_foggy\JPEGImages\\'
rootxmls = 'D:\dataset\cityscapes\cityscape_voc_foggy\Annotations\\'
allusedxmls = []
file_imgs = os.listdir(rootimgs)
file_xmls = os.listdir(rootxmls)
for file_xml in file_xmls:
file_name = file_xml[:-4] + '_foggy_beta_0.005.xml'
oldname = rootxmls + file_xml
newname = rootxmls + file_name
os.rename(oldname, newname)