trying to check the creation date of a file

Discussion in 'Python' started by David Fickbohm, Aug 19, 2005.

  1. People,

    I am trying to determine the creation date of files in a folder.
    I am using the following code to find the folder and confirm that files
    exist in the folder. If someone could give me an idea how to check a
    creation date it would be appreciated.
    Thanks
    dave

    def delete_old_files (t:\dm\~\users)
    # find files and delete files created more than XX number of days
    ago
    update_exist = 0

    input_dir = t:\dm\~\users\xxxx.yyyyyy\zzzz

    if os.path.exists (input_dir) :
    files = os.listdir (input_dir)
    else:
    print "Unable to find input file dir: %s !!!" % input_dir
    sys.exit(2)

    if len(files):
    for file in files :

    file = os.path.join(input_dir) #all files in output
    directory will be csv or xls, can be deleted if old enough

    if os.path.isfile(file): #need to check ext not file, file
    name changes each day
    if re.search(t:\dm\~\users\xxxxx\) and #creation date
    gt x number of days ago
    t:\dm\~\users\davef.input_list.delete(file)

    file_delete = 1

    if file_delete:

    print "\n file deleted: \n%s" %
    str(t:\dm\~\users\xxxxx.input_list)

    return file_delete

    Dave Fickbohm
    Data Mining Analyst
    Homegain+
    1250 45th St.
    Emeryville, CA, 94608
    Phone 510 594 4151 - Voice
    510 655 0848 - Fax
    David Fickbohm, Aug 19, 2005
    #1
    1. Advertising

  2. David Fickbohm

    Larry Bates Guest

    use os.stat docs are here:
    http://docs.python.org/lib/module-stat.html

    Larry Bates

    David Fickbohm wrote:
    > People,
    >
    > I am trying to determine the creation date of files in a folder.
    > I am using the following code to find the folder and confirm that files
    > exist in the folder. If someone could give me an idea how to check a
    > creation date it would be appreciated.
    > Thanks
    > dave
    >
    > def delete_old_files (t:\dm\~\users)
    > # find files and delete files created more than XX number of days
    > ago
    > update_exist = 0
    >
    > input_dir = t:\dm\~\users\xxxx.yyyyyy\zzzz
    >
    > if os.path.exists (input_dir) :
    > files = os.listdir (input_dir)
    > else:
    > print "Unable to find input file dir: %s !!!" % input_dir
    > sys.exit(2)
    >
    > if len(files):
    > for file in files :
    >
    > file = os.path.join(input_dir) #all files in output
    > directory will be csv or xls, can be deleted if old enough
    >
    > if os.path.isfile(file): #need to check ext not file, file
    > name changes each day
    > if re.search(t:\dm\~\users\xxxxx\) and #creation date
    > gt x number of days ago
    > t:\dm\~\users\davef.input_list.delete(file)
    >
    > file_delete = 1
    >
    > if file_delete:
    >
    > print "\n file deleted: \n%s" %
    > str(t:\dm\~\users\xxxxx.input_list)
    >
    > return file_delete
    >
    > Dave Fickbohm
    > Data Mining Analyst
    > Homegain+
    > 1250 45th St.
    > Emeryville, CA, 94608
    > Phone 510 594 4151 - Voice
    > 510 655 0848 - Fax
    >
    >
    Larry Bates, Aug 19, 2005
    #2
    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. Matt
    Replies:
    1
    Views:
    570
    Matthew Speed
    Nov 8, 2003
  2. TN Bella
    Replies:
    5
    Views:
    631
    TN Bella
    Jun 16, 2004
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,193
    Michael Borgwardt
    May 30, 2004
  4. Matt
    Replies:
    2
    Views:
    493
    Pete Becker
    Nov 8, 2003
  5. user
    Replies:
    41
    Views:
    337
    Dr J R Stockton
    Dec 2, 2006
Loading...

Share This Page