PowerTip: Use PowerShell to Count Types of Images

Summary: Use Windows PowerShell to count different types of image files.

Hey, Scripting Guy! Question How can I use Windows PowerShell to see a count of the different types of image files on my computer?

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet to find the image files and then pipe the results to the Group-Object cmdlet,
           for example:

dir -Recurse -ea 0 -File -path e:\data -include "*.gif","*.jpg", "*.png", "*.bmp" | 
group extension -NoElement

Note  Dir is an alias for Get-ChildItem and Group is an alias for Group-Object.

Comments (3)

  1. Sorry, -Recurse not -Recursive. Why is there no edit button on these comments…

  2. Or to have a list of all file types in a folder:

    dir -Recursive |Group Extension -NoElement

  3. Richard Wolff says:

    Just wanted to say I started scripting for work purposes recently your blog has been absurdly useful. I never even check it I just ask google a question and it always sends me here for the answer. So thank you very much for all the hard work and write

Skip to main content