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() for file in os.listdir("e:\usenet\tv"): filepath = os.path.join("e:\usenet\tv", file) if os.stat(filepath).st_mtime < now - 14 * 86400: if os.path.isfile(filepath): os.remove(filepath) elif os.path.isdir(filepath): shutil.rmtree(filepath)

Questions about programming?Chat with your personal AI assistant