generate functionSun, 13 Nov 2022

Delete files named *.tdarrcache* on D:\ only if they are over 2 days old.

import os import time now = time.time() # Delete cache after 2 days cutoff = now - (2 * 86400) for root, dirs, files in os.walk('D:\\'): for name in files: filename = os.path.join(root, name) st = os.stat(filename) if st.st_mtime < cutoff and name.endswith('.tdarrcache'): os.remove(filename)

Questions about programming?Chat with your personal AI assistant