File housekeeping is a seemingly never-ending task for network administrators. Removing temporary files, duplicate data, old service packs, blue-screen-of-death dumps, and unauthorized media files such as MP3s is repetitive and time-consuming. The Dir command, which you issue from a command prompt, is limited in its ability to query for anything more than filename information. You can use wildcards to list files (e.g., dir *.doc), but you can't specify date ranges or file sizes. Windows Explorer provides more flexible search capabilities but doesn't let you output the results to a text file or use scripts to automate searches (Windows Explorer requires human interaction, so you can't automate its features).
To help you perform regular administrative cleanup tasks, you need a command-line utility that can use a variety of criteria to perform directory search operations. I've written a script, edir.vbs, which Listing 1, page 2, shows, that lets you evaluate conditional expressions against files. Instead of wildcards or command-line switches, the Edir utility uses conditional expressions to filter files, so you can use complex criteria when searching. I developed the script under Windows 2000 Service Pack 2 (SP2) with Windows Script Host (WSH) 5.6. The script requires WSH 2.0 or later and VBScript 5.0 or later to execute. I've tested the script under Windows NT 4.0, and it will also run as is under Windows Me and Windows 9x. . . .