hi
I want to zip a folder using python script. I have written below piece of
code, but i found that total size of all file is equal to the size of
resultant zip file. so no compression is done. Its just put all the files in
a folder and say save it with an extension(.zip). May be i am wrong someway,
but i checked it correctly.

import zipfile, os
archive_list = os.listdir("logs_21-01-2010")
# save the files in the archive_list into a PKZIP format .zip file
zfilename = "logs_21-01-2010_.zip"
zout = zipfile.ZipFile(zfilename, "w")
for fname in archive_list:
    fname = "logs_21-01-2010\\"+fname
    print fname
    zout.write(fname)
zout.close()

# test if the file is a valid pkzip file
if zipfile.is_zipfile(zfilename):
    print "%s is a valid pkzip file" % zfilename
else:
    print "%s is not a valid pkzip file" % zfilename

thnks in advance
ah
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to