how to set the time of a directory?

Timothy Grant timothy.grant at gmail.com
Sat Oct 11 01:27:27 EDT 2008


On Fri, Oct 10, 2008 at 10:16 PM, oyster <lepto.python at gmail.com> wrote:
> os.utime works only against files. so what to do for a directory?
> thanx

Not sure why you'd say that.

drwxr-xr-x  2 tjg  tjg       68 Oct 10 22:23 test
(tjg at bastard%) python
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:16)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> help(os.utime)
Help on built-in function utime in module posix:

utime(...)
    utime(path, (atime, mtime))
    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.

>>> os.utime('test', None)
>>> ^D
(tjg at bastard%) ls -ltr
drwxr-xr-x  2 tjg  tjg       68 Oct 10 22:24 test


-- 
Stand Fast,
tjg.  [Timothy Grant]



More information about the Python-list mailing list