generate functionTue, 29 Nov 2022

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

paths = ["E:\usenet\tv\", "E:\usenet\movies\"] for path in paths: 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.remove(f) elif os.path.isdir(f): shutil.rmtree(f)

Questions about programming?Chat with your personal AI assistant