Downloads
40511.zip

Share your scripting discoveries, comments, problems, solutions, and experiences with products. Email your contributions (500 words or less) to r2rwinscriptsol@winnetmag.com. We edit submissions for style, grammar, and length. If we print your submission, you'll get $100.

Automatically Delete Old Files
One of my responsibilities as a network engineer is to manage my company's FTP server. Although we repeatedly ask our users to clean out their directories and delete old files, our server is consistently overloaded. To solve this problem, I decided to write a script to automatically check the DateLastModified parameter and delete old files. Web Listing 1 (http://www.winnetmag.com/windowsscripting, InstantDoc ID 40511) contains my script, which I set Task Scheduler to run weekly. You'll need to modify the script's hard-coded path statements to match your environment.

The script contains a switch that when set to False checks the DateLastModified parameter and prints the results to a .csv file. This report contains the name of the file, date modified, size, and status. The report also tells the user how many files the script will delete and how much space will be freed. The first time I ran the script on my FTP server, I deleted 1165 files and regained 6.5GB of disk space.