≡ Menu

count files by extension using powershell

Just a tip. This will help you to list files count by extension.

Get-Childitem c:\local -Recurse | where { -not $_.PSIsContainer } | group Extension -NoElement | sort count -desc
{ 12 comments… add one }
  • Maria March 13, 2012, 8:18 am

    Awesome – saved my life

  • hamid April 25, 2012, 10:14 am

    hi
    that’s grate
    I need this code
    😉

  • Rob Andren March 6, 2013, 11:01 am

    Brilliant. Glad I didn’t spend any time reinventing the wheel. Exactly what I needed. Thank you.

  • lync August 8, 2014, 8:10 pm

    Thank you – saved my day !!!!

  • Jim October 20, 2014, 7:13 pm

    Just what I needed. Thanks.

  • Brian July 2, 2015, 11:00 pm

    If you’re using a newer version of PS, you can replace the where clause with -file.

    get-childitem c:\local -file |group Extension -NoElement |sort Count -desc

    Don’t know how much faster this is, but there is a performance improvement.

  • mumu July 12, 2018, 1:00 pm

    How to do output in percent (or better both)?
    I don’t have a mind how to do it in one string with only one pass.

  • Lucas September 18, 2018, 8:22 pm

    E para verifica o tamanho ocupado no disco por cada extensão?

    • Wintel Rocks October 8, 2018, 8:30 pm

      No provision available to check the space occupied by each extension type.

  • franz March 12, 2019, 12:31 am

    Awesome! thank you 🙂

  • Casey September 30, 2019, 3:16 pm

    Man… in 2019 this is still gold. If you are using the latest PS version try the following if yours is not working:

    Get-ChildItem C:\windows\system32 -Recurse | Where { -not $_.PSIsContainter } | group Extension | Select Count, Name | Sort Count -Descending

    Cheers!

Leave a Comment