{"id":104,"date":"2017-07-08T12:07:39","date_gmt":"2017-07-08T10:07:39","guid":{"rendered":"http:\/\/developer.ps\/?p=104"},"modified":"2026-09-22T20:52:17","modified_gmt":"2026-09-22T18:52:17","slug":"python-script-to-extract-file-creation-dates","status":"publish","type":"post","link":"https:\/\/developer.ps\/index.php\/2017\/07\/08\/python-script-to-extract-file-creation-dates\/","title":{"rendered":"Python script to extract file Creation dates"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#!\/usr\/bin\/env python\r\n\r\nimport os, csv, sys, subprocess, hashlib, time, pytz\r\nfrom datetime import timedelta, datetime, tzinfo\r\nimport pytz\r\nimport tzlocal\r\n\r\nwriter = csv.writer(sys.stdout, quoting=csv.QUOTE_ALL)\r\nil = pytz.timezone('Israel')\r\nlocal_timezone = tzlocal.get_localzone() # get pytz timezone\r\nwith open('file.csv', 'w', newline='', encoding='utf-8') as csvfile:\r\n    spamwriter = csv.writer(csvfile, delimiter=',',\r\n            quotechar='\"', quoting=csv.QUOTE_MINIMAL)\r\n    for directory, subdirectories, filenames in os.walk('PATH'):\r\n        \r\n        unix_timestampc = float(os.path.getctime(directory))\r\n        \r\n        unix_timestamp = float(os.path.getmtime(directory))\r\n        \r\n        spamwriter.writerow([directory,unix_timestampc,unix_timestamp])\r\n        \r\n        for filename in filenames:\r\n            #h = hashlib.md5()\/\/if has is needed\r\n            full_filename = os.path.join(directory, filename)\r\n            unix_timestampc = float(os.path.getctime(full_filename))\r\n            unix_timestamp = float(os.path.getmtime(full_filename))\r\n            spamwriter.writerow([directory+\"\\\\\"+filename,unix_timestampc,unix_timestamp])\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/usr\/bin\/env python import os, csv, sys, subprocess, hashlib, time, pytz from datetime import timedelta, datetime, tzinfo import pytz import tzlocal writer = csv.writer(sys.stdout, quoting=csv.QUOTE_ALL) il [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/comments?post=104"}],"version-history":[{"count":1,"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/posts\/104\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/media?parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/categories?post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.ps\/index.php\/wp-json\/wp\/v2\/tags?post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}