zut.file.archivate_file

zut.file.archivate_file(path: str | PathLike, archive: Literal[True] | str | os.PathLike | None = None, *, prefix: str | None = None, missing_ok: Literal[False] = False, keep: bool = False) Path
zut.file.archivate_file(path: str | PathLike, archive: Literal[True] | str | os.PathLike | None = None, *, prefix: str | None = None, missing_ok: Literal[True], keep: bool = False) Path | None
zut.file.archivate_file(path: str | PathLike, archive: Literal[False], *, prefix: str | None = None, missing_ok: bool = False, keep: bool = False) None

Archivate path to archive directory, ensuring unique archive name.

Parameters:
  • archive – By default (if None), use the same directory as the origin path. If relative (e.g. ‘archive’), it is relative to the directory of the original path.

  • prefix – Prefix to use on the archive file names. For example, use . to make them hidden files under Linux.

  • missing_ok – If True, do not throw an exception if the original file does not exist.

  • keep – If True, the original file is not removed after archiving.