\[Editor's Note: Share your scripting discoveries, comments, problems, solutions, and experiences with products. Email your contributions (500 words or less) to email@example.com. We edit submissions for style, grammar, and length. If we print your submission, you'll get $100.\]
I read Moussa Faty's Reader to Reader: "Delete Files by Age" (March 2003, http://www.winscriptingsolutions.com, InstantDoc ID 37718), and I know of an easier way to delete files by age. The Microsoft Windows 2000 Server Resource Kit's Forfiles tool performs a command on each file in a list. For example, if you want to purge all the files in a directory that are older than 10 days, you can go to a command prompt and enter
forfiles -pC:\logfiles\ -m*.* -d-10 -s -c"cmd /c del @FILE"
The -p option is the directory in which to search for files, the -m option selects the files that match the specified string, the -d option specifies the date or days, the -s option recurses subdirectories, and the -c option is the command you want to run.