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
Cool, easy, quick, and accurate. Don’t you agree?
Latest posts by Kent Chen (see all)
- The Page File (PageFile.sys) Guide for Windows 7, 8.1 and 10 - February 22, 2017
- How To Enable and Use Fetch Files Feature in OneDrive to Access All Your Files Remotely - February 21, 2017
- Speed Up Email Search for Outlook and Gmail with Email Insight App - February 20, 2017
Last updated: 08/04/2014