How can I change the timestamps of directories? (os.utime(), WinXP)

Martin Bless m.bless at
Thu Dec 9 17:05:44 CET 2004

I'm working on a backup scheme that looks at modification times. To
run some tests I'd like to be able to set the modification time of
directories (WinXPsp2, Python-2.3.4)

os.utime() works well with files but throws a permission error with
directories. See code below.

Q: Can this be done via the os-module?
Q: Is it possible at all? Somebody knows?


mb - Martin Bless

Trying to the timestamps of a directory
import sys, os, stat, datetime, time
today =
pastday = today - datetime.timedelta(days=11)
atime = int(time.mktime(pastday.timetuple()))
mtime = atime
times = (atime,mtime)
path = os.path.normpath(r'c:/dummydir')

""" throws error:
OSError: [Errno 13] Permission denied: 'c:\\dummydir'

More information about the Python-list mailing list