Recipe 7.14. Finding Large Files and Folders on a Volume


Problem

You want to find files or folders that exceed a certain size on a volume.

Solution

Using a graphical user interface

  1. From the Start menu, select Search.

  2. If you are presented with the options for what to search on, click All files and folders.

  3. Click on What size is it?

  4. Select the radio button beside Specify size and enter the size you want to search.

  5. Select additional criteria if necessary and click Search.

Using a command-line interface

The following command finds folders that are greater than 100 MB in size on the D drive:

> diruse /s /m /q:100 /d d:

The /s option causes subdirectories to be searched, the /m option displays disk usage in megabytes, the /q:100 option causes folders that are greater than 100 MB to be marked, and the /d option displays only folders that exceed the threshold specified by /q.

Use the diskuse command to find files over a certain size. The following command displays files over 100 MB in size on the D drive:

> diskuse D: /x:104857600 /v /s

The /x:104857600 option causes files over 104,857,600 bytes to be displayed and is valid only if you include the /v option (verbose). The /s option means subdirectories from the specified path (in this case the D drive) are searched.

Using downloadable software

The DiskPie Pro utility from PC Magazine (http://www.pcmag.com/article2/0,1759,1616002,00.asp) can, among other things, display the largest files on a particular drive. Figure 7-1 shows an example of the largest files on the C drive.

Figure 7-1. DiskPie Pro utility


DiskPie Pro is available for free to PC Magazine subscribers or can be purchased for $5.97 by itself. Other features include displaying the total size of files with a particular type and monitoring folders that exceed a certain size.

Using VBScript
' This code finds all files over a certain size. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ComputerName>"  intSizeBytes = 1024 * 1024 * 500  ' = 500 MB ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colFiles = objWMI.ExecQuery _     ("Select * from CIM_DataFile where FileSize > '" & intSizeBytes & "'") for each objFile in colFiles     Wscript.Echo objFile.Name & "  " & objFile.Filesize / 1024 / 1024 & "MB" next

Discussion

If you find that you are running out of space on a volume and want to see what is consuming the most space, you are better off using the diruse command-line solution. With the other solutions, you could search for all files over 100 MB, for example, but a user could have created a bunch of 10 MB MPEG files. Unfortunately, you can't use the Search dialog box or VBScript to search on folder sizes, which leaves diruse as the most appropriate tool in this scenario.

See Also

Recipe 7.7 for cleaning up disk space and MSDN: CIM_DataFile



Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net