i'm using python2.7 to extract zip files under windows - created by 7z.exe. Now if i use zip.extractall(), the extracted files have a modfied date, which causes some problems in later prosessing these file. Now, how can i preserve the timestamp of each file extracted. I think i want the "last modified" attribute? Here is my unzip function:
def unzip(src, dst):
lst = []
try:
dst = os.path.normpath(dst)
if not os.path.exists(dst):
os.makedirs(dst)
os.chdir(dst)
src = os.path.normpath(src)
zip = zipfile.ZipFile(src, "r")
lst = zip.namelist()
zip.extractall()
zip.close()
except zipfile.BadZipfile as e:
print "Zip error. Couldn't open zip file:", src
except IOError as e:
print "I/O-Error while extracting", \
os.path.basename(src), \
"({0}): {1}".format(e.errno, e.strerror)
return lst