Get oldest folder

Tim Golden mail at timgolden.me.uk
Tue Apr 15 10:36:57 EDT 2008


jyoung79 at kc.rr.com wrote:
> 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