keep original date and time of unzipped files

  • Thread starter Bartolomé Sintes Marco
  • Start date
B

Bartolomé Sintes Marco

Hi,

In this mail,
http://www.mail-archive.com/[email protected]/msg00030.html
Kragen Sitaker explained how to unzip a file in Python

#!/usr/local/bin/python
# learn how to use zipfile module

import sys, zipfile, os, os.path

def unzip_file_into_dir(file, dir):
os.mkdir(dir, 0777)
zfobj = zipfile.ZipFile(file)
for name in zfobj.namelist():
if name.endswith('/'):
os.mkdir(os.path.join(dir, name))
else:
outfile = open(os.path.join(dir, name), 'wb')
outfile.write(zfobj.read(name))
outfile.close()

def main():
unzip_file_into_dir(open(sys.argv[1]), sys.argv[2])

if __name__ == '__main__': main()

The unzipped files date and time are not the original ones, but
when the unzipping is done. Is there a way to keep the
original files date and time?

Thanks,
Barto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top