Newbie question

Jason Orendorff jason at jorendorff.com
Wed Jan 30 19:29:51 EST 2002


> I am running Python 2.2 on Win2k.  How do I read the contents/files 
> contained in a directory and also date created and dump it into a 
> textfile or csv file?

import os
import time

DIR = "C:\\mydir"
for filename in os.listdir(DIR):
    full_path = os.path.join(DIR, filename)
    created = os.stat(full_path).st_ctime
    print filename + ",", time.ctime(created)

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list