I am trying to do something with directories older than 4 days. Here is what I have:
from datetime import datetime, date
#get current time
curret_time = datetime.now()
#get file creation time
stat = os.stat(my_directory)
creation_time = datetime.fromtimestamp(stat.st_birthtime)
#get the age of directory
age_of_directory=curret_time - creation_time
#I want to remove any directory that is older than 4 days
if age_of_directory > 4:
#shutil.rmtree(my_directory)
print(age_of_directory) #debugging line
Error I get is:
TypeError: '>' not supported between instances of 'datetime.timedelta' and 'int'
How do a fix this issue?