generate functionSat, 12 Nov 2022

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

import os, time def remove(path): now = time.time() for file in os.listdir(path): file_path = os.path.join(path, file) # Delete the files if over 2 days old if os.stat(file_path).st_mtime < now - 2 * 86400 and file.endswith(".tdarrcache"): os.remove(file_path) remove(r"D:\")

Questions about programming?Chat with your personal AI assistant