generate functionTue, 29 Nov 2022

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

import os, time, datetime path = "E:\usenet\tv\" now = time.time() print(now) for root, dirs, files in os.walk(path): for name in files: filename = os.path.join(root, name) if os.stat(filename).st_mtime < now - 14 * 86400: if os.path.isfile(filename): os.remove(filename) print(filename) elif os.path.isdir(filename): os.rmdir(filename) print(filename)

Questions about programming?Chat with your personal AI assistant