archive

Contents

archive#

archive(folder_path: str | CloudPath | Path, archive_path: str | CloudPath | Path, fmt: str = 'zip') CloudPath | Path[source]#

Archives a folder recursively.

Parameters:
  • folder_path (AnyPathStrType) – Folder to archive

  • archive_path (AnyPathStrType) – Archive path, with or without extension

  • fmt (str) – Format of the archive, used by shutil.make_archive. Choose between [zip, tar, gztar, bztar, xztar]

Returns:

Archive filename

Return type:

str

Example

>>> folder_path = 'D:/path/to/folder_to_archive'
>>> archive_path = 'D:/path/to/output'
>>> archive = archive(folder_path, archive_path, fmt="gztar")
'D:/path/to/output/folder_to_archive.tar.gz'