# Retrieve File Dates for Files Inside an Archive (ZIP)

Suppose I have a zip archive file with many files in it. I can get a list of the files in the archive with:

Import["zipfile.zip"]


I can get data out of one of the files inside the archive with:

Import["zipfile.zip","somefile.txt"]


I can get the date the zip file was created with

FileDate["zipfile.zip"]


But I can't figure out how to get the dates of the files inside the zip file.

• I can verify there is no way to do this currently without extracting the file first. This is a good suggestion, we'll look into this for future versions. – GenericAccountName Apr 4 at 2:34

I know you are probably looking for a pure Mathematica solution - looks like it's not supported by Mathematica (yet). However, don't forget that you can run any external program and analyze its output in Mathematica, so e.g. on macOS I can use unzip, which provides data in the following format:

17:06 /tmp $unzip -l archive.zip Archive: archive.zip Length Date Time Name --------- ---------- ----- ---- 0 04-03-2019 17:06 a.txt 0 04-03-2019 17:06 b.txt 0 04-03-2019 17:06 c.txt --------- ------- 0 3 files 17:07 /tmp$


and therefore I can write this Mathematica function to do date processing for me:

zipDates[filename_] :=
Interpreter["Date"]@
StringSplit[
StringSplit[
RunProcess[{"unzip", "-l", filename}, "StandardOutput"],
"\n"][[4 ;; -3]],
" "][[All, 3]]


• Thanks for the reminder. Using an external function is a great idea. I'm using windows so I'll give this a try with 7-Zip. – Rudy Potter Apr 9 at 20:03