Get oldest folder

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    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=pyth on-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_timestam p=time.time()
    413 folders=listdir (share_dir)
    414 for folder in folders:
    415 if isdir(join(shar e_dir,folder)):
    416 if stat(join(share _dir,folder)).s t_ctime < oldest_timestam p:
    417 oldest_timestam p=stat(join(sha re_dir,folder)) .st_ctime
    418 oldest_folder=f older
    419 return join(share_dir, oldest_folder)

    Thanks for looking at my question.

    Jay
Working...