import osimport platform
def creation_date(path_to_file):"""Try to get the date that a file was created, falling back to when it waslast modified if that isn't possible.See http://stackoverflow.com/a/39501288/1709587 for explanation."""if platform.system() == 'Windows':return os.path.getctime(path_to_file)else:stat = os.stat(path_to_file)try:return stat.st_birthtimeexcept AttributeError:# We're probably on Linux. No easy way to get creation dates here,# so we'll settle for when its content was last modified.return stat.st_mtime
from crtime import get_crtimes_in_dir
for fname, date in get_crtimes_in_dir(".", raise_on_error=True, as_epoch=False):print(fname, date)# file_a.py Mon Mar 18 20:51:18 CET 2019