Get oldest folder

Discussion in 'Python' started by Guest, Apr 15, 2008.

  1. Guest

    Guest Guest

    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_ctime
    418 oldest_folder=folder
    419 return join(share_dir,oldest_folder)

    Thanks for looking at my question.

    Jay
     
    Guest, Apr 15, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    3
    Views:
    2,943
    Alvin Bruney
    Oct 16, 2003
  2. William LaMartin

    _vti_cnf folder in the bin folder-- a problem?

    William LaMartin, Nov 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,703
    Oliver
    Nov 10, 2003
  3. Replies:
    6
    Views:
    470
    Lauri Raittila
    Jun 13, 2005
  4. Replies:
    4
    Views:
    439
  5. Chris McMahon

    Oldest Ruby hacker?

    Chris McMahon, Oct 24, 2005, in forum: Ruby
    Replies:
    13
    Views:
    172
    Charles Roper
    Oct 28, 2005
Loading...

Share This Page