import os os.rename("Dir", "DirNew") from pathlib import Path data_file = Path("Dir") data_file.rename("DirNew")