import pathlib import shutil ckpt_paths = pathlib.Path("./").glob("**/model.ckpt") for ckpt_path in ckpt_paths: print(ckpt_path) shutil.move( ckpt_path, f"{ckpt_path.parent/ ckpt_path.parent.stem}.ckpt" ) print(f"{ckpt_path.parent/ ckpt_path.parent.stem}.ckpt")