MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Mon, Jun 21, 2010 6:10 pm

Finding Large Files on a Windows System from the Command Line

You can find all files over 99 MB in size and store the file names in a text file with the command below:

dir C:\ /a-d/s | findstr "[0-9][0-9][0-9],[0-9].*,[0-9]" | findstr /v "[er](s)" > bigfiles.txt

You can use dir /a-d to select only files and not directories. The /a option means that you want to display files with the specified attributes. Directories are specified by d; specifying a -d means select everything that is not a directory.

The /s option for the dir command indicates that you want to display files in the specified directory and all of its subdirectories.

You can use the findstr command to filter the output of the dir command. If I only wanted to see files that were at least 10 MB or more, I could use findstr "[0-9][0-9],[0-9].*,". To send the output of the dir command to the findstr command, you use the |, which is the pipe symbol, e.g., dir /a-d/s | findstr "[0-9][0-9],[0-9].*,". The information between the double quotes is a "regular expression" that tells the findstr command what to look for in the input it receives. I want it to look for two numbers, followed by a comma, then another number, then zero or more characters and then another comma. The [0-9] tells finstr to look for any character in the numeric set, i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. Since I include [0-9] twice, findstr looks for two numbers, one after the other. The dot, ., is used to represent any character and the * following it states the character can occur zero or more times. Then another comma should appear. That command dir /a-d/s | findstr "[0-9][0-9],[0-9].*,", might produce the following output.

C:\Documents and Settings\administrator>dir /a-d/s | findstr "[0-9][0-9],[0-9].*
07/30/2002  04:27p          35,417,061 savceclt.exe                             
               5 File(s)     36,390,066 bytes                                   
             217 File(s)     38,486,808 bytes                                   
               0 Dir(s)     469,125,120 bytes free

I don't want the "File(s) and "Dir(s)" lines. I can eliminate them by sending the outpout of the findstr command to another findstr command, i.e., dir /a-d/s | findstr "[0-9][0-9],[0-9].*," | findstr /v "[er](s)". The /v option to findstr tells findstr to display only lines that do not contain a match. In this case, I tell it to look for either an "e" or "r" followed by "(s)" and to discard any lines that match.

:\Documents and Settings\administrator>dir /a-d/s | findstr "[0-9][0-9],[0-9].*
," | findstr /v "[er](s)"                                                       
07/30/2002  04:27p          35,417,061 savceclt.exe

In the case above, I've found all files greater than 10 MB in the administrator's "My Documents" directory or beneath it. If I want to search the entire system for files 100 MB or greater, I could use the following commands:

C:\Documents and Settings\administrator>dir C:\ /a-d/s | findstr "[0-9][0-9][0-9
],[0-9].*,[0-9]" | findstr /v "[er](s)" > bigfiles.txt

Those commands start at the root directory, C:\ and search for all files within that directory or beneath it that are over 99 MB. The >bigfiles.txt redirects the output of the last command to a file named bigfiles.txt.

Examing the bigfiles.txt file, I might see something like the following:

C:\Documents and Settings\administrator>type bigfiles.txt                       
06/21/2010  05:21p         267,948,032 hiberfil.sys                             
06/21/2010  05:21p         314,572,800 pagefile.sys                             
06/09/2010  05:49p         277,297,548 Deleted Items.dbx                        
06/09/2010  05:49p         151,866,224 Inbox.dbx                                
06/09/2010  05:49p         144,463,812 Sent Items.dbx                           
10/27/2009  08:51p         949,861,964 Inbox                                    
06/20/2010  07:48p       1,014,070,855 Sent                                     
03/13/2010  04:42p       2,148,821,701 Inbox                                    
06/21/2010  03:47p         388,459,482 Sent                                     
06/21/2010  05:00p         201,147,392 personal.pst                             
 Directory of C:\Program Files\PhoneTools\vocfiles\WAVMS,11025,8,1              
07/27/2007  09:03a         119,977,472 500dc2a.msp                              
07/27/2007  09:03a         119,977,472 5a34890.msp                              
09/14/2007  01:16p         113,491,064 MAINSP3.CAB

In the case above, there was one line that was included that I didn't actually want just because it did fit the pattern I was looking for, i.e., the WAVMS,11025,8,1 line. But I would expect entries like that to be rare, so I'm not concerned about it in this case.

The directory where the file was found won't be listed, but you can look through bigfiles.txt and then locate particular files listed in it and then make the current directory the root directory with cd \ and then search all subdirectories for the file name as in the example below:

C:\Documents and Settings\administrator>cd \                                    
C:\>dir /s 500dc2a.msp                                                          
 Volume in drive C has no label.                                                
 Volume Serial Number is F4D7-D263
 Directory of C:\WINDOWS\Installer                                              
07/27/2007  09:03a         119,977,472 500dc2a.msp                              
               1 File(s)    119,977,472 bytes                                   
     Total Files Listed:                                                        
               1 File(s)    119,977,472 bytes                                   
               0 Dir(s)     471,283,200 bytes free

[/os/windows/commands] permanent link

Once You Know, You Newegg AliExpress by

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo