470,636 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

Get oldest folder

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 at "http://trac.v2v.cc/browser/python-v2v/v2v/v2v.py?rev=python-v2v%2C37", but was curious if there's a better way to do this?

def get_oldest_v2v_folder():
404 '''
405 returns the oldest folder in share_dir
407 is this the right way to check for the oldest folder?
408 could be better to read the info file and
409 extract the date there.
410 '''
411 global share_dir
412 oldest_timestamp=time.time()
413 folders=listdir(share_dir)
414 for folder in folders:
415 if isdir(join(share_dir,folder)):
416 if stat(join(share_dir,folder)).st_ctime < oldest_timestamp:
417 oldest_timestamp=stat(join(share_dir,folder)).st_c time
418 oldest_folder=folder
419 return join(share_dir,oldest_folder)

Thanks for looking at my question.

Jun 27 '08 #1
0 847

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by totoringo2004 | last post: by
reply views Thread by Tim Golden | last post: by
reply views Thread by | last post: by
1 post views Thread by Korara | last post: by
reply views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.