11

Possible Duplicate:
How to get file creation & modification date/times in Python?

I would like to get the created date and time of a folder. Are there anyways to do that in python?

Thank you

Community
  • 1
  • 1
Ricky
  • 323
  • 2
  • 5
  • 11
  • The question has been answered [here](http://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times-in-python). Check it out ;-). – OnesimusUnbound Oct 03 '11 at 06:54
  • And one more thing I would like to ask, for example I create a folder named "file" on 25.08.2011 at 01:58:00. When I copy this folder to other directory, its created date and time changed.So, how can I get the date and time on 25.08.2011 at 01:58:00, even when the folder is copied to other directory. :( – Ricky Oct 03 '11 at 10:08

1 Answers1

24

You might use os.stat to retrieve this information.

os.stat(path).st_mtime      // time of most recent content modification,
os.stat(path).st_ctime      // platform dependent; time of most recent metadata change on Unix, or the time of creation on Windows)
Howard
  • 38,639
  • 9
  • 64
  • 83
  • And one more thing I would like to ask, for example I create a folder named "file" on 25.08.2011 at 01:58:00. When I copy this folder to other directory, its created date and time changed.So, how can I get the date and time on 25.08.2011 at 01:58:00, even when the folder is copied to other directory. :( – Ricky Oct 03 '11 at 10:02
  • Thank you for the distinction between Unix and Windows with respect to st_ctime – Arthur Hebert-Ryan Aug 16 '19 at 20:59