Created
March 24, 2012 21:40
-
-
Save PHLAK/2188297 to your computer and use it in GitHub Desktop.
Deletes files older than 14 days from a given folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
path = "E:\\Downloads" | |
now = int(time.time()) | |
dirList = os.listdir(path) | |
for fileName in dirList: | |
filePath = path + "\\" + fileName | |
modTime = int(os.path.getmtime(filePath)) | |
if now - modTime >= 1209600: | |
print "Deleting %s" % filePath | |
os.remove(filePath) | |
print "Cleanup complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment