Show all files and folders in MB/GB in Windows 11/10


👤 Diwas Poudel    🕒 Jul 29 2022    📁 TECH

The most common way for most Windows users to check the size of a folder is to open the folder properties in File Explorer. However, the file size displayed will be in KB. Furthermore, you prefer to see all file sizes at a glance in human-readable units such as MB or GB rather than bytes and KB. 

By default, Windows will display all its files size in KB, and sometimes reading this size is difficult because manually you have to convert the bytes size or KB to either MB/GB as these Units are much familiar to us.

Also, as far as I know, there is no default way of converting units of measurement in Windows Explorer. So, we need to perform tweaks on it.

Ourtechroom will guide you in showing all files in MB/GB Windows 11/10.

Using Powershell Get-ChildItem Cmd key

Open PowerShell and type the following scripts.

Get-ChildItem "C:\DemoFolder" -File | ForEach-Object {'{0:N5} {1}' -f @(($_.Length / 1mb), $_.FullName)}

Get-ChildItem is a command that directs the computer to return all of the files found in a given path. In my particular instance, the path is C: DemoFolder. It will list the filename in a tabular manner and display the size of the file in megabytes. It will display filesize with up to five decimal places after the decimal point.

Actually, the script that you just ran did not find all of the files in the subfolder. If you want to display recursively all of the files that are placed anywhere, even inside subfolders and subfolders within subfolders, then you need to type the following command.

Get-ChildItem "C:\DemoFolder" -File -Recurse -Force | ForEach-Object {'{0:N5} {1}' -f @(($_.Length / 1mb), $_.FullName)}

-Recurse and -Force: Recursively search for parameters in all files in the directory and subdirectories.

If you want to include only a certain type of file then you can do the following:

Get-ChildItem "C:\DemoFolder" -File -Recurse -Force -Include .zip,.txt,.mp4 | ForEach-Object {'{0:N5} {1}' -f @(($_.Length / 1mb), $_.FullName)}

Here we are including zip, txt, and mp4 and its filesize in MB

Similarly, if you want to exclude then you can use it like this:

Get-ChildItem "C:\DemoFolder" -File -Recurse -Force -Include .zip,.txt,.mp4 -Exclude C1F2,TempFolder | ForEach-Object {'{0:N5} {1}' -f @(($_.Length / 1mb), $_.FullName)}

Here we are excluding C1F2 and TempFolder.

Also read: Ultimate Guide to create and run PowerShell Scripts

Using Powershell GCI Command Cmd key

GCI is a short form for Get-childItem. So, you can use it as follows:

gci "C:\DemoFolder" | select @{n="MB";e={"{0:n5} MB" -f ($_.Length / 1MB)}}, FullName

Using Command Line 

You can also use the command prompt for displaying the file size. Just open a command prompt and type the following.

powershell -command "Get-ChildItem "C:\DemoFolder" -File | ForEach-Object {'{0:N5} {1}' -f @(($_.Length / 1mb), $_.FullName)}"

Here, powershell -command helps you to display the PowerShell command to run in the command prompt. Here Powershell script is included in double quotation as shown above.

Also read: Run multiple commands in one line in Powershell and Cmd

Using External Software

There are lots of software that shows the file and its filesize in the desired filesize. One of that software is TreeSize.Let's look into this software.

1. Download TreeSize software from this link.

2. Click on Select Directory from the menu and select the desired folder you want to display their property including filesize.

3.  Click on Automatic Units and then select Values in MB. Now you will get all files and folder names and their size in MB.

treeview software
fig. View file and folder in MB in TreeView Software

Conclusion:

In this way, we are showing all files in MB/GB Windows 11/10.

FAQ:

How to determine the size of all user profiles in the C: Users folder?

The command for this is as follows:

gci -force 'C:\Users'-ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$_.fullname, '{0:N5} MB' -f ($len / 1Mb)
}
What are Mb and MB?

Even though the terms are pronounced similarly and their acronyms contain the same letters, megabits and megabytes do not refer to the same unit of measurement. Their relationship is as follows:

8 Mb = 1 MB = 2^20 bytes = 1048576 bytes 

 

👊 MORE FROM OURTECHROOM 👊



Ourtechroom Main Logo
Hello and thank you for visiting Ourtechroom.com! We'll talk about everything from how to troubleshoot tech issues, to emerging technology, games, gadgets, and fun facts about technology.
Contact : ourtechroom777@gmail.com