ID EN
OS

rename

Python 3.11

Rename the file or directory src to dst. If dst exists, the operation will fail with an OSError subclass in a number of cases:

Syntax

PYTHON
os.rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)

See Also

OSError FileExistsError shutil.move() IsADirectoryError NotADirectoryError OSError paths relative to directory descriptors replace()