Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   How can I change the timestamps of directories? (os.utime(), WinXP) (http://www.velocityreviews.com/forums/t339031-how-can-i-change-the-timestamps-of-directories-os-utime-winxp.html)

Martin Bless 12-09-2004 04:05 PM

How can I change the timestamps of directories? (os.utime(), WinXP)
 
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?

Thanks,

mb - Martin Bless


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

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



Matt Gerrans 12-09-2004 10:40 PM

Re: How can I change the timestamps of directories? (os.utime(), WinXP)
 
Are you able change this directories attributes in a command shell or with
explorer? If so, have you tried win32file.SetFileAttributes()?




All times are GMT. The time now is 04:13 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.