Globbing files by their creation date

tkpmep at hotmail.com tkpmep at hotmail.com
Wed Jan 17 11:31:07 EST 2007


Thanks a mill - os.path.getctime(f) is what I needed. Unfortunately, my
attempts to turn the integer it returns into a date have failed.

>>> os.path.getctime(fn)    #fn was created today, 1/17/2007
1168955503

I tried to convert this to a date object by typing
>>>datetime.date.fromordinal(1168955503)

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in -toplevel-
    datetime.date.fromordinal(1168955503)
ValueError: year is out of range

How can I do the conversion? I'm trying to identify all files that were
created after YYYY/MM/DD.

For a quick sanity check, I ran
>>> datetime.date.today().toordinal()
732693

which is orders of magnitude smaller than the number returned by
os.path.getctime(fn).

Thanks in advance for your help

Thomas Philips




More information about the Python-list mailing list