0

I’m using shutil.unpack_archive function to unpack a zip file, but it changes the “Date modified” attribute. How can I unpack an archive without changing the metadata of its content in Python?

martineau
  • 119,623
  • 25
  • 170
  • 301
Sameera
  • 304
  • 1
  • 19
  • Date Modified refers to when the file was modified, and that "modification" can be for any reason, such as opened the file, saved new content or in this case "unzip". I don't suppose there's an option to change the metadata., Here have a look at this https://stackoverflow.com/questions/3081444/changing-a-files-metadata-in-python – Sahil Sep 06 '19 at 09:24
  • Do you mean the "Date modified" attribute of the archive file? – Pynchia Sep 06 '19 at 09:24
  • I meant the date modified of the content – Sameera Sep 06 '19 at 09:26
  • 2
    Try using the [`zipfile`](https://docs.python.org/3/library/zipfile.html#module-zipfile) module. – martineau Sep 06 '19 at 09:27
  • 2
    There's also [this discussion](https://stackoverflow.com/questions/9813243/extract-files-from-zip-file-and-retain-mod-date-python-2-7-1-on-windows-7) showing ways keep the modified timestamp. –  Sep 06 '19 at 09:31

0 Answers0