Although this is unlikely to change things tremendously, it very inefficient to do your date calculations 90,000 times. You could get the current system date, calculate only once what is the current date minus 90 days (or 93 days, whatever you really need, your code is at variance with your description of the requirement on that point) and then only start to look at your directories and the files' last change date.