Python Forum

Full Version: get "Birthdate" from File inside a Zipfile
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using the zipfile Module to extract and detect the Birthdate of a file inside a Zip, but as soon as i extract the file to get the Date from the File i recieve the current Date when the File was extracted. Doesnt the Zipfile Module support getting the "real" Birthdate of the File or is there an Option to preserve the Date and just copy it when extracting ?


the Code i use currently is

from zipfile import ZipFile
		with ZipFile('f:/myfile.zip', 'r') as zipObj:
  		 # Get a list of all archived file names from the zip
			listOfFileNames = zipObj.namelist()
  		 # Iterate over the file names
			for fileName in listOfFileNames:
			 # Check filename endswith .diz
				if fileName.endswith('.diz'):
					zipObj.extract(fileName, 'f:/temp_diz')	
			 # Extract file_id.diz from zip
		create_date = os.stat("f:/temp_diz/file_id.diz")[8]
		print (time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(create_date)))