Just another IT WordPress site

Main menu

Post navigation

Get File Type Size and Count

Did you ever wanted to know the number of dll files in C:Windows ? How much megabytes it represent ? Maybe you have a C:Script folder and want to know the number of .ps1 files against the number of .vbs files ? Maybe you want some knowledge about the data stored on your files servers ? Maybe you want to know the different types of photo you own ?You can do it with PowerShell, just set the location of your prompt and use those lines :

What is does ? First, it grabs all the files and folders in directory you are in. Then, it exclude the directories, and group file by extension, and finally, for each extension, it measure the number of files, and the size of them. There is some maths for MB/GB display with some composite formatting.

Get File Type Size – Example :

For C:Windows, you may want to use “Out-GridView” for a readable output :