I know for a fact that os.stat
functions well on both windows
and linux
.
Documentation here
However, to fit your functionality, you could do:
You can use st_atime
to access most recent access and st_ctime
for file creation time.
import os,time
def get_information(directory):
file_list = []
for i in os.listdir(directory):
a = os.stat(os.path.join(directory,i))
file_list.append([i,time.ctime(a.st_atime),time.ctime(a.st_ctime)]) #[file,most_recent_access,created]
return file_list
print get_information("/")
I'm on a mac
and I get this,
[['.dbfseventsd', 'Thu Apr 4 18:39:35 2013', 'Thu Apr 4 18:39:35 2013'], ['.DocumentRevisions-V100', 'Wed May 15 00:00:00 2013', 'Sat Apr 13 18:11:00 2013'],....]