listing files by modification time

Chris Rebert clp2 at rebertia.com
Tue Feb 17 07:36:52 EST 2009


On Tue, Feb 17, 2009 at 4:31 AM, Deepak Rokade <smartpawn at gmail.com> wrote:
> Hi,
>
> I am using python 2.5 on sun solaris.
>
> I want to limit the number of files returned by os.listdir() to some number
> (say 1000), how can I do it ?
>
> Also I wan to list the files only if they are older than some x days, how
> can I do it?

You can filter the returned list of files by checking the results of
os.stat() [http://docs.python.org/library/os.html#os.stat] on the
files. The `stat` module [http://docs.python.org/library/stat.html]
can help with the interpretation of the data returned from os.stat().

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list