Convert folder to Zip

PHOTO EMBED

Wed Oct 11 2023 06:03:45 GMT+0000 (Coordinated Universal Time)

Saved by @20ucs113 #python

import os
import zipfile

def zipdir(path, ziph):
    # ziph is zipfile handle
    for root, dirs, files in os.walk(path):
        for file in files:
            ziph.write(os.path.join(root, file),
                       os.path.relpath(os.path.join(root, file),
                                       os.path.join(path, '..')))

with zipfile.ZipFile('/content/m1.Zip', 'w', zipfile.ZIP_DEFLATED) as zipf:
    zipdir('/content/m1', zipf)
content_copyCOPY

Zip folder
https://colab.research.google.com/drive/1rZhSnQnWyigw4kgUQAFY3PQIO3HA6La2#scrollTo=sv6XyqFcTrxl