How to change a file's date/timestamp?

Discussion in 'Python' started by pythos, Aug 20, 2004.

  1. pythos

    pythos Guest

    How do you change a file's last-modified date and timestamp in Python?
     
    pythos, Aug 20, 2004
    #1
    1. Advertisements

  2. pythos

    Peter Hansen Guest

    pythos wrote:

    > How do you change a file's last-modified date and timestamp in Python?


    utime(...)
    utime(path, (atime, utime))
    utime(path, None)

    Set the access and modified time of the file to the given values.
    If the second form is used, set the access and modified times to the
    current time.


    This and many other functions are in the 'os' standard module, one
    of the few very very widely used and useful modules... you should
    read the online docs for it, along with "sys", and "time" at least,
    before doing any more coding. ;-)

    -Peter
     
    Peter Hansen, Aug 20, 2004
    #2
    1. Advertisements

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:
    838
    Matthew Speed
    Nov 8, 2003
  2. [XaToA]
    Replies:
    1
    Views:
    516
    Roedy Green
    Jul 30, 2003
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,786
    Michael Borgwardt
    May 30, 2004
  4. Matt
    Replies:
    2
    Views:
    753
    Pete Becker
    Nov 8, 2003
  5. Matt
    Replies:
    3
    Views:
    936
    Richard Heathfield
    Nov 8, 2003
  6. praba kar

    change the date string into timestamp

    praba kar, Apr 9, 2005, in forum: Python
    Replies:
    2
    Views:
    533
    Fabio Pliger
    Apr 9, 2005
  7. Matt
    Replies:
    11
    Views:
    647
    Aaron Bertrand [MVP]
    Nov 8, 2003
  8. Replies:
    0
    Views:
    293
Loading...