How to compress a folder and all of its sub directories and files into a zip file?
peter at rt.sk
Tue Jun 28 19:29:23 CEST 2005
What about this:
from os.path import join
zip = zipfile.ZipFile("myzipfile.zip", 'w')
for root, dirs, files in os.walk('.'):
for fileName in files:
Maybe it zips also the myzipfile.zip ;-)
Probably this is not needed, so an additional test (something like
fileName != 'myfile.zip' would be needed.
could ildg wrote:
> I want to compress a folder and all of its sub files including empty folders
> into a zip file. what's the pythonic way to do this?
> Thanks in advance.
More information about the Python-list