UPDATE:
I have resolved my issue after some time on various sites and tutorials on time handling in Python, as well as much trial and error. This method should be Windows and Unix compatible, unlike all the tutorials I found for doing this (they involved importing Win32 modules and too much junk).
Here is my testing code:
import os, time
#path to file
file = 'C:\\test\\time.txt'
#get current file stats
stats = os.stat(file)
#convert time to a more useable format
lastmod_date = time.localtime(stats[8])
#print the last date of modification
print(lastmod_date)
#new value to be stored in "Date Modified" file attribute
modDate = (2009, 2, 4, 20, 20, 12, 6, 39, 0)
#print new value (to compare against modified file
print(modDate)
#convert time to a value the system can handle
SysTime = time.mktime(modDate)
#print the value after conversion
print(SysTime)
#update the file attributes
os.utime('C:\\test\\time.txt', (int(time.time()), SysTime))
Yes, I know some of the variable names are a bit odd and should be changed, but it got the job done for testing.
I may do some more work on this such as refining the code, making it accept user input, and possibly adding a quick GUI and then toss it all in a tutorial.
This post has been edited by dwayne: 08 February 2009 - 06:09 PM

Start a new topic
Add Reply




MultiQuote
| 


