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?
Asked
Active
Viewed 917 times
0
-
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
-
2Try using the [`zipfile`](https://docs.python.org/3/library/zipfile.html#module-zipfile) module. – martineau Sep 06 '19 at 09:27
-
2There'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