#-*- coding:utf-8 -*-
import os
from datetime import date, timedelta, time, datetime
filePath = '경로'
days = 60
def listUp():
fileList = os.listdir(filePath)
return fileList
def date_delta(base_date):
yy = int(base_date[:4])
mm = int(base_date[5:7])
dd = int(base_date[8:10])
d = date(yy,mm,dd)
return (date.today() - d).days
def run():
tod = date.today()
sortList = listUp()
sortList.sort()
for path in sortList:
if date_delta(path) > days:
print "remove file : ", filePath, path
removeFile = os.path.join(filePath,path)
os.remove(removeFile)
if __name__ == "__main__":
print "start"
run()
print "end"