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)
- Microsoft Pauses New Insider Preview Builds for the New Unified Update Platform - December 7, 2016
- How To Disable Removable USB Storage Read, Write and Execute Access on Windows 10 - December 1, 2016
- Windows 10 Tip: How To Move System Tray to the Second Display - November 30, 2016
Last updated: 08/04/2014