#!/usr/bin/python # -*- coding: -*- from __future__ import print_function import os import time current_time = time.time() for file in os.listdir(): creation_time = os.path.getctime(file) if (current_time - creation_time) // (24 * 3600) >= 7: os.unlink(file) print('{} removed'.format(f))