Get oldest folder

jyoung79 at kc.rr.com jyoung79 at kc.rr.com
Wed Apr 16 10:00:20 EDT 2008


Hi Tim,

Thanks very much for your help!  I'm still just learning Python and really appreciate seeing other peoples examples on how they work with Python.  Thanks again for taking the time to share this.

Jay

>> I'd like to be able to get the path to the oldest folder in whatever directory 
>> I'm currently in.  Is there a simple way to go about this?  
>> I'd like it to run on both OS X and Windows XP.  
>> I found this example but was curious if there's a better way to do this?

>Better: I don't know. Alternative, certainly:

><code>
>import os, glob

>PATH = "c:/python25/lib/site-packages"
>print min ((f for f in glob.glob (os.path.join (PATH, "*")) if os.path.isdir (f)), key=os.path.getctime)

></code>


>TJG



More information about the Python-list mailing list