Globbing files by their creation date

James Antill james-netnews at and.org
Tue Jan 16 15:33:52 EST 2007


On Tue, 16 Jan 2007 07:44:29 -0600, skip wrote:

> Thomas> I've used glob.glob to create a list of all files whose name
>     Thomas> matches a substring, but I don't see how I can use it to
>     Thomas> identify files by their creation date.
> 
> 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.

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 -- james at and.org
http://www.and.org/and-httpd/ -- $2,000 security guarantee
http://www.and.org/vstr/



More information about the Python-list mailing list