generate functionTue, 29 Nov 2022

Delete files and folders older than 14 days in "E:\usenet\tv\"

import os import shutil import time path = "E:\usenet\tv\" now = time.time() for f in os.listdir(path): f = os.path.join(path, f) if os.stat(f).st_mtime < now - 14 * 86400: if os.path.isfile(f): os.unlink(f) elif os.path.isdir(f): shutil.rmtree(f)

Questions about programming?Chat with your personal AI assistant