sertit.files.archive

archive(folder_path: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], archive_path: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], fmt: str = 'zip') Union[cloudpathlib.cloudpath.CloudPath, pathlib.Path][source]

Archives a folder recursively.

>>> 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'
Parameters
  • folder_path (Union[str, CloudPath, Path]) – Folder to archive

  • archive_path (Union[str, CloudPath, Path]) – 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