Re: Checking a file's time stamp -- followup

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Virgil Stokes

    Re: Checking a file's time stamp -- followup

    Christian Heimes wrote:
    >William Purcell wrote:
    >>Hi all,
    >>I am wanting to check to see the last time a file was edited. For
    >>example, I
    >>have a directory containing two text files, file1.txt and
    >>file2.txt. I
    >>want to be able to process these files but only if they have been
    >>edited
    >>since the last time they were processed. I think that I want to be
    >>able to
    >>check the time stamp of each file. Can anyone tell me how to do that or
    >>point me in a better direction of checking the last time a file was
    >>edited?
    >>
    >>
    > >>import os
    > >>stat = os.stat("/etc/passwd")
    > >>print stat
    >(33188, 362259, 2053L, 1, 0, 0, 1690, 1218550501, 1218118498,
    >1218118498)
    > >>dir(stat)
    >['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
    >'__eq__', '__ge__', '__getattribute __', '__getitem__',
    >'__getslice__' , '__gt__', '__hash__', '__init__', '__le__',
    >'__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__',
    >'__reduce_ex__ ', '__repr__', '__rmul__', '__setattr__', '__str__',
    >'n_fields', 'n_sequence_fie lds', 'n_unnamed_fiel ds', 'st_atime',
    >'st_blksize' , 'st_blocks', 'st_ctime', 'st_dev', 'st_gid', 'st_ino',
    >'st_mode', 'st_mtime', 'st_nlink', 'st_rdev', 'st_size', 'st_uid']
    > >>stat.st_mti me
    >1218118498.0
    >>
    >
    use these shortcuts, IMHO they are easier than os.stat.
    >
    os.path.getmtim e() - get modified time
    os.path.atime() - get last accessed time (careful some admins turn
    this
    off on their servers for performance reasons)
    os.path.ctime() - get creation time
    >
    >
    -Larry
    Is it possible to change the time stamp of a file (Win2K platform)? If
    yes, how?
Working...