Determine Free Disk Space
Beyond the traditional tasks of managing event log entries, configuration files, and processes, other tasks are more specific to typical day-to-day operations, such as copying files. Evaluating the total file size of a collection of files and making sure enough disk space exists on a target location before executing a copy or move operation can be crucial, particularly if the amount of data you need to copy or move is large. If you don't want to write a WSH script to handle this operation but still want a way to automate the verification, you can combine Cmd.exe statements with two tools available in Windows 2003: Forfiles.exe and Freedisk.exe. Listing 1 shows a sample script that does just that. The Forfiles command within the line at callout A is:
Forfiles.exe /S /M *.DAT /C "Cmd /c echo @fsize"
This line echoes all *.dat file sizes on the screen. The /S switch specifies that the search must be done in the current folder and all subfolders, and the /M switch specifies that all *.dat files be searched. The /C switch defines the command to execute for each file that Forfiles finds. In this case,
"Cmd /c echo @fsize"
simply outputs the size of each found file on the screen. . . .