difficult zipefile Question

matthiasjanes matthiasjanes at gmx.net
Wed Oct 6 18:37:18 EDT 2004


hello all,

i want to zip a folder plus the files and subfolders.

which works something like that:

#sample code

import os, zipfile

def zipit(path, ziper):

  for root, dirs, files in os.walk(path):

    for anyFile in files:

      fullname = os.path.join(root, anyFile)
                
if __name__ == '__main__':

  ziper = zipfile.ZipFile('test.zip', 'w')
  zipit('somefolderTozip', ziper)
  ziper.close()
#____________________________


this works fine as long as there is no empty subfolder.

can anyone tell me - or better give me a small example of code how to
add an empty folder to the zip archive.

thanks mr. janes



More information about the Python-list mailing list