By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,651 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

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

P: n/a
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'
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Are you able change this directories attributes in a command shell or with
explorer? If so, have you tried win32file.SetFileAttributes()?
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.