.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/zip_folders.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_zip_folders.py: zip folders =========== This example demonstrates zipping the subfolders of a parent directory. .. GENERATED FROM PYTHON SOURCE LINES 13-14 Import lsframe, import shutil for creating the zip files, and import os for defining paths, .. GENERATED FROM PYTHON SOURCE LINES 14-18 .. code-block:: default import lsframe as ls import shutil import os .. GENERATED FROM PYTHON SOURCE LINES 21-22 Set the path to a parent directory full of folders you would like to zip, .. GENERATED FROM PYTHON SOURCE LINES 22-23 .. code-block:: default path = "../path/to/parent/directory" .. GENERATED FROM PYTHON SOURCE LINES 27-28 Create the start object, create a directory_map, and make a frame from the directory_map with depth of 1 consisting only of folders. This means the names column of the frame consists of the names of the folders that reside at the given path, .. GENERATED FROM PYTHON SOURCE LINES 28-31 .. code-block:: default lsobject = ls.start(directory=path) lsobject.map_directory() lsobject.map_to_frame(depth=1, kind="folders") .. GENERATED FROM PYTHON SOURCE LINES 34-35 Scan through the names of the folders collected in the frame and create zip files of the contents, .. GENERATED FROM PYTHON SOURCE LINES 35-39 .. code-block:: default [ shutil.make_archive(os.path.join(path, name), "zip", os.path.join(path, name)) for name in lsobject.frame.name ] .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_zip_folders.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: zip_folders.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: zip_folders.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_