generate functionTue, 29 Nov 2022

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

import os, time now = time.time() cutoff = now - (14 * 86400) for root, dirs, files in os.walk('E:\usenet\tv\\'): for name in files: fullpath = os.path.join(root, name) if os.path.getmtime(fullpath) < cutoff: if os.path.isfile(fullpath): os.remove(fullpath)

Questions about programming?Chat with your personal AI assistant