Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Get oldest folder

Reply
Thread Tools

Get oldest folder

 
 
Guest
Posts: n/a
 
      04-15-2008
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
406
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.

Jay
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FYI: Pythons Were the Oldest Gods Doug.Fort@gmail.com Python 0 12-14-2006 07:09 PM
oldest laptop owners Toolman Tim Computer Support 25 10-05-2005 04:56 PM
Oldest Laptop owners Martik Computer Support 17 10-04-2005 05:16 AM
Oldest usable computer for development ? msswasstastic@aol.com HTML 6 06-13-2005 06:52 PM
open oldest unread message first, possible? Cloud Burst Computer Support 3 10-04-2004 04:34 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57