a problem in datetime.interval()
lameck kassana
lkassana at gmail.com
Mon Mar 9 05:57:28 EDT 2009
hi ,
I am writing a scriot which will move old files from one directory to backup
The files are in mode *20090307* mean *yyyymmmdd* to new files.
The script is below is like this
*import os
import datetime
import time
from datetime import date
today=date.today()*
*for x in range(5,10):
interval=datetime.timedelta(x)
print interval
today=today-interval
today=today.strftime("%Y%m%d")
print today
src=r"f:\Sql_Loader\SMR\file_log_backup\smr"+today+"*"
dest=r" f:\Sql_Loader\SMR\file_log_backup2"
print src
print dest
os.system(r"move " +src+" "+ dest)*
but the error is like that
*Traceback (most recent call last):
File "remove_old_files.py", line 10, in <module>
today=today-interval
TypeError: unsupported operand type(s) for -: 'str' and 'datetime.timedelta'
*
It seems datetime.timedelta()does not respond with my loop
Any help??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090309/c4a71bec/attachment.html>
More information about the Python-list
mailing list