Easily Counting Different Types of Files on Your Computer


There are a few ways you can count the specific types of files on a particular folder on your computer. For example, you can use the old school command line Dir with /s, or you can use the search feature in Windows 7 and 8. Or, you can use something even cooler that can not only count one specific type but many types at once.

Here is how you can achieve it using PowerShell, thanks to the Scripting Guy for the trick.

Basically, it uses the Get-ChildItem cmdlet to recursively scan a particular folder to retrieve specified types of files you want to count, and then pipe the results through to Group-Object cmdlet, with grouping on the Extension property with the -NoElement switch to remove the individual file information.

To simplify this, let’s just see an example that counts the number of files for JPG, PNG, TIF, DOC, and DOCX in my H: drive. Open PowerShell console and run the following command:

Get-ChildItem -Recurse -Include *.jpg, *.png, *.tif, *.doc, *.docx | Group-Object Extension -NoElement

Windows PowerShell Get ChildItem 600x94 - Easily Counting Different Types of Files on Your Computer

Cool, easy, quick, and accurate. Don’t you agree?


  1. If for some reason you have to generate a report like this on a system where PowerShell isn’t available (.NET issues, old OS, etc.), you can generate a similar report using Microsoft’s LogParser. Contrary to its name, LogParser does more than read log files and can treat the file system as a database that can be accessed using SQL type queries.

    But Powershell is so flexible……!

  2. To get file extension count for all files, just replace the explicit file extensions with *.*

    Get-ChildItem -Recurse -Include *.* | Group-Object Extension -NoElement

  3. This is a helpful Powershell command, but the results seem to be limited to 9999.
    Can this Powershell command be modified to count over 100,000 file types?

    At the moment I’m using this command, which searches the directories and subdirectories of “F:\Documents” and does a count of .xls files, but disregards the case of the file extension.

    dir /s “F:\Documents” | find /c /i “.xls”



Please enter your comment!
Please enter your name here