title: Python zip multiple directories into one zip file
body: <p>I have a top directory <code>ds237</code> which has multiple sub-directories under it as below:</p>
  
  <pre><code>ds237/
  ├── dataset_description.json
  ├── derivatives
  ├── sub-01
  ├── sub-02
  ├── sub-03
  ├── sub-04
  ├── sub-05
  ├── sub-06
  ├── sub-07
  ├── sub-08
  ├── sub-09
  ├── sub-10
  ├── sub-11
  ├── sub-12
  ├── sub-13
  ├── sub-21
  ├── sub-22
  ├── sub-23
  ├── sub-24
  ├── sub-25
  ├── sub-26
  ├── sub-27
  ├── sub-28
  ├── sub-29
  </code></pre>
  
  <p>I am trying to create multiple zip files(with proper zip names) from ds237 as per size of the zip files. 
  <code>sub01-01.zip: contain sub-01 to sub-07</code>
  <code>sub08-13.zip : it contains sub08 to sub-13</code></p>
  
  <p>I have written a logic which creates a list of sub-directories <code>[sub-01,sub-02, sub-03, sub-04, sub-05]</code>. I have created the list so that the total size of the all subdirectories in the list should not be > 5gb.</p>
  
  <p><strong><em>My question:</em></strong> is how can I write a function to zip these sub-dirs (which are in a list) into a destination zip file with a proper name.
  Basically i want to write a function as follows:</p>
  
  <p><code>def zipit([list of subdirs], 'path/to/zipfile/sub*-*.zip'):</code></p>
  
  <p>I Linux I generally achieve this by:</p>
  
  <pre><code>'zip -r compress/sub01-08.zip ds237/sub-0[1-8]'
  </code></pre>