批量更改图片名称
import os filepath = r'E:\ML\Pytorch\train\cleavage/' n= 0 if __name__ == "__main__": print("start") if not os.path.exists(filepath): print("目录不存在!!") os._exit(1) filenames = os.listdir(filepath) for data in filenames: oldname = filepath + filenames[n] newname = n print(newname) newname=filepath + 'cleavage' + '_' +str(n) + '.jpg' os.rename(oldname,newname) n=n+1