My Windows 7 search is pretty slow on one computer and fast on the other. I figured out that one computer has 90,000 files indexed while the other has 1.5 million.

So I'd like to find the biggest folders by number of files, since some are bound to be irrelevant, and exclude them.

I have tools for finding the biggest folders by data size, but not by number of files within. Any ideas?


If you were using Windows XP, you could use the Folder Size shell-extension which gives you a few columns that you can add to Explorer to show the size of a folder, as well as the number files/folders/both contained therein, thus allowing you to view and sort them right inside Explorer.

Unfortunately, Vista and higher have dropped the API functionality that Folder Size and similar programs use, so they no longer work.

Instead, you’ll have to use a non-shell-extension. Fortunately there are several programs that can do a pretty good job of visualizing space usage on a file-system.

Most of them have a few different modes including text-list/tree (like in Explorer), pie-graph, and treemap, in which the files and sub-directories are represented by squares or rectangles. There should be an option to display the number of files/folders in addition to the size, usually in text-list/tree mode. Sometimes, to get the number of files/folders, you need to select the folder and view its properties (which is less convenient, but still easier than manually in Explorer).

Here are some of the most popular ones (some freeware, others shareware):

  • 1
    Yup, WinDirStat is the quickest and easiest because the default view has the number of items right there in the list. – Synetech Jun 30 '11 at 0:36
  • 1
    WinDirStat is my favorite too. – KCotreau Jun 30 '11 at 1:58

And another, TreeSize Free. (In this shot, the directories are named 0-F.)

enter image description here


One quick way to get a sorted list of folders by number of files - including subfolders - is:

PowerShell 3+

Get-ChildItem 'D:\' -Recurse -Directory -ErrorAction Ignore | Foreach {
    $a[$_.Fullname] = (Get-ChildItem $_.Fullname -Recurse -File -ErrorAction Ignore).Count
$a.GetEnumerator() | Sort Value -Descending | Format-List

Example output

enter image description here

For those who are interested in how it works

  • Get-ChildItem 'D:\' -Recurse -Directory loops through all subfolders of a given directory. Change the path to your needs
  • In each subfolder use (Get-ChildItem $_.Fullname -Recurse -File).Count to count the number of files including files in subfolders. Folders itself don't count. Only files do.
  • For each subfolder, add a new hash table entry $a[$_.Fullname] = myValue with the current directory as name. As value add our previously mentioned files count
  • After all the work is done, use $a.GetEnumerator() to break the hash table back into multiple items and pipe them to a Sort-Object command which sorts the hash table by value and ascending

I use a program called windirstat which scans through all the files and folders on a drive and gives a nice graphical display of which files or folders are using the most space. You can then move or delete unwanted files and tidy up your disk.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.