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 To-Do App Available in Preview on Windows 10, iOS and Android - April 19, 2017
- Windows 10 Tip: What’s Mini View in Movies & TV App and How To Use it - April 15, 2017
- Windows 10 Tip: How To Convert MBR Partition to GPT without Losing Data - April 12, 2017
Last updated: 08/04/2014