Possible Duplicate:
Batch file to delete files older than N days
I'm trying to make a DoS Batch file to go through a directory with about 500,000 files in it, and i would like it to delete all the files older then 1 year
Here's my code so far
@echo off
title File Exclusion Act
for /f "usebackq delims=|" %%f in (`dir /b "C:\Users\Travis\Desktop\LotsOfFiles"`) do echo %%f
pause
So far it loops and prints out all the files in the specified directory.
Any tips/help is highly appreciated.
Best Solution
The Batch file below must be called with the number of days for old files to remove from today. For example, use 365 to remove 1 year old files.
If your %date% format is not MM/DD/YYYY, reorder mm, dd and yy variables in the first line of :DateToJDN subroutine.