Thanks in advance for the assistance.
Thomas Philips
Sumthin' like:
files = [f for f in glob.glob(globpat)
if os.path.getctime(f) > timethreshold]
Define globpat and timethreshold accordingly. You sure you don't mean
modification time? If so, change getctime to getmtime.
Skip
help(os.path.getctime)
getctime(filename)
Return the metadata change time of a file, reported by os.stat().
Note that _change_ time != creation time. Also for all files you probably
want os.listdir() instead of glob.
--
James Antill -- ja...@and.org
http://www.and.org/and-httpd/ -- $2,000 security guarantee
http://www.and.org/vstr/
>>> 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
Ordinals are unrelated to the values given back by getctime. Try something
like this instead:
exarkun@charm:~$ python
Python 2.4.3 (#2, Oct 6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import datetime
>>> datetime.date.fromtimestamp(os.path.getctime('.'))
datetime.date(2007, 1, 17)
>>>
exarkun@charm:~$ ls -ld .
drwxr-xr-x 93 exarkun exarkun 8192 2007-01-17 10:34 .
exarkun@charm:~$
Jean-Paul