simple UnZip

noydb jenn.duerr at
Wed Jul 2 15:39:51 CEST 2008

Can someone help me with this script, which I found posted elsewhere?
I'm trying to figure out what is going on here so that I can alter it
for my needs, but the lack of descriptive names is making it
difficult.  And, the script doesn't quite do anything worthwhile -- it
unzips one file from a zipfile, not all files in a zipfile.

import zipfile, os, sys, glob

zips = glob.glob('*.zip')

for fzip in zips:
    if zipfile.is_zipfile(fzip):
        print fzip," is a zip"
        z = zipfile.ZipFile(fzip,'r')
        lstName = z.namelist()
        sHgt = lstName[0]
        print "Unpacking",sHgt
        hgt =
        fHgt = open(sHgt,'wb')
        # fHgt.flush
print "Finished"

I changed it somewhat to
import zipfile, os, sys

event_zip = ("C:\\Temp\\")

z = zipfile.ZipFile(event_zip, 'r')

zList = z.namelist()

for zItem in zList:
    print "Unpacking",zItem
    zRead =
    z1File = open(zItem,'wb')
print "Finished"

This works, but I want to be able to specify a different output

The scenario is that the zip file will always be the same (gets copied
over daily), but it needs to be unzipped to a specific different

Can anyone help?


More information about the Python-list mailing list