Where was all my disk space going? I went to google and searched for something that would tell me and couldn't find anything I liked. So I wrote this simple VBS script that will list all files and directories starting at a given point and sort them by size. Note this script does not account for space taken by Alternate Data Streams.
To execute this script open a command window and type "cscript listfilesbysize START OUT". Replace START with the path of the directory you want to start in and OUT with the base name of the output file to be created. Assuming that there are no errors with the execution the actual output file will have the name OUT.sorted. Bear in mind that the more files and directories you have the longer it takes for this command to finish. It took over 6 minutes to scan my C:\ drive containing slightly over 28 GB "Used Bytes".
Example 1 - List all files in the current directory and all subdirectory and place the outut in a file called x.sorted
H:\projects\VB scripts>cscript listfilesbysize.vbs . x Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. H:\projects\VB scripts>The x.sorted file looks this. I have removed a great many lines but you should get the idea. Note that files are listed first then directories. Directories have a "D" at the begining of the line.
This run of ListFilesBySize done at 9/23/2006 6:30:51 PM 0 H:\projects\VB scripts\x 43 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\leftframe_file\dtbar_file\1pix.gif 43 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\leftframe_file\search_file\1pix.gif 43 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\rightframe_file\contentbar_file\1pix.gif 67 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\leftframe_file\dtbar_file\hidetoc1.gif . . . 37102 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\toolbar_file\toolbar.js 77562 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\rightframe_file\win32_networkadapterconfiguration.htm D 615 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\leftframe_file\dtbar_file D 2716 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\leftframe_file\deeptree_file D 3127 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\rightframe_file\contentbar_file D 5558 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\leftframe_file\search_file D 20165 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file\leftframe_file . . . D 235863 H:\projects\VB scripts\Win32_NetworkAdapterConfiguration_file
Example 2 - List all files on the C drive and place the output in the file c:\c.sorted
H:\projects\VB scripts>cscript listfilesbysize.vbs c:\ c:\c Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. H:\projects\VB scripts>I'm not going to list the contents of c.sorted. Other than the file paths the contents of c.sorted and x.sorted look pretty much the same.
REM ListFilesBySize.vbs begins here REM REM Version 1.0 06-09-23 REM Version 1.1 10-11-26 Added disclaimer REM Noah Davids - ndav1@cox.net REM REM REM This software is provided on an "AS IS" basis, WITHOUT ANY WARRANTY OR ANY SUPPORT OF ANY KIND. REM The AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY REM PARTICULAR PURPOSE. This disclaimer applies, despite any verbal representations of any kind provided REM by the author or anyone else. option explicit dim objFSO dim outFilePath dim outFile const ForWriting = 2 const pad = " " dim WshShell On Error Resume Next if WScript.Arguments.Count <> 2 then WScript.Echo "Usage:" WScript.Echo vbtab & "cscript ListFilesBySize.vbs |