- Folder Sizes in Windows Explorer
- Get Folder Size from Windows Command Line
- 18 Answers 18
- Folder Size Explorer — Free Windows Explorer with folder sizes.
- Folder Size is a freeware tool that will scan and list folder sizes on your computer, print folder sizes or print files list.
- Supported OS: Windows 10 / Windows 8 / Windows 7 / Windows Vista / Windows XP / Windows 98 including x86 and x64 32 bit and 64 bit operating systems.
- Supported server OS: Windows Server 2003 / Home Server / Server 2008 / EBS 2008 / HPC Server 2008 / Server 2008 R2 / Home Server 2011 / Server 2012 / MultiPoint Server / Small Business Server
- PowerShell: Get Folder Sizes on Disk in Windows
Folder Sizes in Windows Explorer
Microsoft’s Windows Explorer has been one of its core applications since Windows 95. It is essentially a task-based file management application that is central to the functioning of Windows. One of the peculiarities of Windows Explorer, seeing that it is a file management application, is that it does not have the ability to display folder sizes. This seems to be a feature that users want but it has never been fully implemented by Microsoft.
The most likely reason it does not display folder sizes is that it would slow down browsing of the file system significantly. To show the size of a folder, Windows Explorer would have to read ever file within every sub-folder before it could return a result. Unfortunately, this takes time and uses up a lot of the systems processing power. Regardless, it seems odd that they didn’t provide it as an option in Explorer’s settings. The column for size is already there for files so it would just be a matter of writing the code to calculate the folder size when the option is enabled.
Nevertheless, Explorer does provide some features to help users calculate folder sizes. The easiest and most well known method is to use the context menu and check the properties of the folder. If you right click a folder and select properties Explorer will recursively scan every file and display the total size as it progresses in the properties window you can see in the screenshot on the right. This works well though sometimes it’s hard to know when the process has finished as it can pause for a time before continuing on. It would be nice to see something that tell you it’s completed at the end. The main problem with this method though is that you have to right click every folder to get its size. As soon as you close the properties window the information is lost. It’s a shame it’s not added to the size column so that you don’t have to write it down or right click the folder again. This makes it very time consuming when you’re trying to quickly determine which folders are using up the most disk space on your drive.
Another way to see the size of a folder is to place your mouse cursor over the folder and wait for the pop-up tool tip to appear. Though this feature works fine for smaller folders it’s pretty useless for larger ones. For example, when I place my mouse over the c:\windows folder as shown in the screenshot below, the tooltip just states that it’s larger than 7MB. Actually, it’s probably best to disable this feature altogether to improve performance when using Explorer. This feature has been known to cause lengthy delays when browsing certain folders like those on a network. This feature is enabled by default in Windows 7 and can be turned on or off via Explorer’s menu by clicking Organize — Folder and search options — View tab — display file size information in folder tips (screenshot below).
Still, none of the above methods for calculating folder sizes provides a simple and quick way to help you find the folders that are taking up the majority of disk space on your local drive or network. For this reason Folder Size Explorer was created as a freeware application. Folder Size Explorer is a simple Windows Explorer clone that displays the file system items exactly as Explorer would except with the added option to calculate folder sizes. It also provides columns for folder count, file count and file checksums calculations should you need them. The folder size calculation can be enabled or disabled quickly by clicking an icon on the toolbar. You can change the size notation of the size column in Explorer with the click of a button from bytes to megabytes, kilobytes or gigabytes. During the folder size calculation it allows you to press escape or cancel at any time to stop the scanning so as to quickly display the standard folder and file items. You can also press the skip button to skip the size calculation of a particular folder that is taking too long to calcualte and move on to the next.
Finally, unlike the native Windows Explorer you can export and save a list of the files and folders with all their columns of information to a csv file. These csv files can then be opened and manipulated in external programs such as Excel, Word and Notepad. Another nice feature about Folder Size Explorer is that you can search for folders containining a specific string and then calculate their size. The same feature allows you to export custom lists of items to csv or calculate MD5, SHA-1 or SHA-256 checksums of matched items only. Below are a couple of screenshots of Folder Size Explorer on Windows 7 and 8.1. It has been designed to be as simple and clean as possible supporting Windows XP, Vista, 7, 8 and Windows Server 2003, 2008, 2012 including R2. (Both x86 and x64 versions are supported). Folder Size Explorer can be downloaded for free here.
Get Folder Size from Windows Command Line
Is it possible in Windows to get a folder’s size from the command line without using any 3rd party tool?
I want the same result as you would get when right clicking the folder in the windows explorer → properties.
18 Answers 18
You can just add up sizes recursively (the following is a batch file):
However, this has several problems because cmd is limited to 32-bit signed integer arithmetic. So it will get sizes above 2 GiB wrong 1 . Furthermore it will likely count symlinks and junctions multiple times so it’s at best an upper bound, not the true size (you’ll have that problem with any tool, though).
An alternative is PowerShell:
If you want it prettier:
You can use this directly from cmd :
1 I do have a partially-finished bignum library in batch files somewhere which at least gets arbitrary-precision integer addition right. I should really release it, I guess 🙂
There is a built-in Windows tool for that:
This will print a lot of unnecessary information but the end will be the folder size like this:
If you need to include hidden folders add /a .
I suggest to download utility DU from the Sysinternals Suite provided by Microsoft at this link http://technet.microsoft.com/en-us/sysinternals/bb896651
While you are at it, take a look at the other utilities. They are a life-saver for every Windows Professional
Same but Powershell only:
This should produce the following result:
If you have git installed in your computer (getting more and more common) just open MINGW32 and type: du folder
Here comes a powershell code I write to list size and file count for all folders under current directory. Feel free to re-use or modify per your need.
I recommend using https://github.com/aleksaan/diskusage utility which I wrote. Very simple and helpful. And very fast.
Just type in a command shell
and get list of folders arranged by size
This example was executed at 272ms on HDD.
You can increase depth of subfolders to analyze, for example:
and get sizes not only for selected folders but also for its subfolders
*** 3.5Tb on the server has been scanned for 3m12s**
This code is tested. You can check it again.
I guess this would only work if the directory is fairly static and its contents don’t change between the execution of the two dir commands. Maybe a way to combine this into one command to avoid that, but this worked for my purpose (I didn’t want the full listing; just the summary).
I got du.exe with my git distribution. Another place might be aforementioned Microsoft or Unxutils.
Once you got du.exe in your path. Here’s your fileSizes.bat 🙂
I think your only option will be diruse (a highly supported 3rd party solution):
The Windows CLI is unfortuntely quite restrictive, you could alternatively install Cygwin which is a dream to use compared to cmd. That would give you access to the ported Unix tool du which is the basis of diruse on windows.
Sorry I wasn’t able to answer your questions directly with a command you can run on the native cli.
::Get a number of lines that Dir commands returns (/-c to eliminate number separators: . ,) [«Tokens = 3» to look only at the third column of each line in Dir]
FOR /F «tokens=3» %%a IN (‘dir /-c «%folderpath%»‘) DO set /a i=!i!+1
Number of the penultimate line, where is the number of bytes of the sum of files:
Finally get the number of bytes in the penultimate line — 3rd column:
As it does not use word search it would not have language problems.
Limitations:
- Works only with folders of less than 2 GB (cmd does not handle numbers of more than 32 bits)
- Does not read the number of bytes of the internal folders.
Change C:\Program Files to whatever folder you want and change %A to %%A if using in a batch file
It returns the size of the whole folder, including subfolders and hidden and system files, and works with folders over 2GB
It does write to the screen, so you’ll have to use an interim file if you don’t want that.
The following script can be used to fetch and accumulate the size of each file under a given folder.
The folder path %folder% can be given as an argument to this script ( %1 ).
Ultimately, the results is held in the parameter %filesize%
Note: The method calcAccSize can also print the content of the folder (commented in the example above)
So here is a solution for both your requests in the manner you originally asked for. It will give human readability filesize without the filesize limits everyone is experiencing. Compatible with Win Vista or newer. XP only available if Robocopy is installed. Just drop a folder on this batch file or use the better method mentioned below.
To be able to use this batch file conveniently put it in your SendTo folder. This will allow you to right click a folder or selection of folders, click on the SendTo option, and then select this batch file.
To find the SendTo folder on your computer simplest way is to open up cmd then copy in this line as is.
Folder Size Explorer — Free Windows Explorer with folder sizes.
Folder Size is a freeware tool that will scan and list folder sizes on your computer, print folder sizes or print files list.
Supported OS: Windows 10 / Windows 8 / Windows 7 / Windows Vista / Windows XP / Windows 98 including x86 and x64 32 bit and 64 bit operating systems.
Supported server OS: Windows Server 2003 / Home Server / Server 2008 / EBS 2008 / HPC Server 2008 / Server 2008 R2 / Home Server 2011 / Server 2012 / MultiPoint Server / Small Business Server
Download Folder Size
Share this great free tool — Your friends will thank you!
Organizing the data in your system can be a real pain in the long run. Data tends to get accumulated in every system, regardless of the type of use that it is put to. And users almost always ignore the steady accumulation and fail to organize it in due time. This leads to an overflow of data, which ultimately leads to a crisis.
For the ones among you who can relate to this, Folder Size is the right software for you. Folder Size is a freeware, its superb simplicity will make you fall in love with the software.
Folder Size analyzes your hard drives space and checks your files and folders and displays exactly how much space each file and folder is occupying.
Download Folder Size
This application hardly occupies any space on the hard drive, it is really compact, fast and also very efficient.
The application displays how much space each file and folder is occupying exactly, on top of this, the application also displays the total percentage of the disk space the files and folders occupy, so it shows the amount of disk space it is occupying and also the percentage.
It displays a report which shows the files and folders which occupy the maximum space first and the ones which occupy lesser space after that, it basically displays them in descending order, starting from the maximum.
When the report is shown, you can easily see which folders are occupying the maximum space as Folder Size also scans the sub folders, yet another bonus that is sure to leave you gaping in awe.
Folder Size scans your entire hard drive in just a few minutes due to its optimized scan algorithms, it also has the another feature, which is its progressive scan which lets you continue the scan right from the point of interruption.
This application is not feature rich, but really simple and displays your hard disk space in the Windows Explorer. Folder Size is a software which is really easy to use.
Download Folder Size
In order to save time, you can also scan particular folders instead of the entire hard drive. Folder Size also keeps a track of which folders you view and scan in the background of the Windows Explorer. It is very useful in the disk cleanup process.
Once you get used to having all the directory sizes and other information there, a directory listing looks very incomplete and odd without it. The application comes with options for deleting specific files and folders, and also listing the various folders present in a very comprehensive way. It also has charting options, something that cannot be found in any other software.
PowerShell: Get Folder Sizes on Disk in Windows
The most of Windows users get used that the easiest way to check the size of a folder is to open the folder properties in Windows Explorer. More experienced users prefer to use tools like TreeSize or WinDirStat. However, if you want to get a detailed statistics on the size of folders in the specific directory or exclude certain file types, you’d better use the PowerShell scripts. In this article we’ll show you how to quickly get the size of the specific folder on the disk (or all subfolders) using PowerShell.
You can use the Get-ChildItem (gci alias) and Measure-Object (measure alias) cmdlets to get the sizes of files and directories in PowerShell.
The first cmdlet allows you to get the list of files in the specified directory by the certain criteria, and the second one performs an arithmetic operation.
For example, to get the size of c:\ps folder, run the following command:
Get-ChildItem c:\iso | Measure-Object -Property Length -sum
As you can see, the total size of files in this directory is shown in the Sum field and is about 2.1 GB (the size is given in bytes).
To convert the size into more convenient MB or GB, use this command:
(gci c:\iso | measure Length -s).sum / 1Gb
(gci c:\iso | measure Length -s).sum / 1Mb
To round the result to two decimals, run the following command:
» <0:n2>GB» -f ((gci c:\iso | measure Length -s).sum / 1Gb)
To calculate the total size of all files of a certain type in a directory, use this command (for example you want to get the total size of all ISO files in a folder):
(gci c:\iso *.iso | measure Length -s).sum / 1Mb
The commands shown above allow you to get only the total size of files in the specified directory. If there are subfolders in the directory, the size of files in the subfolders won’t be calculated. To get the total size of files in the directory taking subfolders into account, use the –Recurse parameter. Let’s get the total size of files in the C:\Windows directory:
» <0:n2>GB» -f ((gci –force c:\Windows –Recurse -ErrorAction SilentlyContinue| measure Length -s).sum / 1Gb)
To take into account the size of hidden and system files, I have used the –force argument as well.
So the size of C:\Windows on my local drive is about 16 GB.
You can get the size of all first-level subfolders in the specified directory. For example, you want to get the size of all user profiles in the folder C:\Users.
gci -force ‘C:\Users’-ErrorAction SilentlyContinue | ? < $_ -is [io.directoryinfo] >| % <
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % < $len += $_.length >
$_.fullname, ‘ <0:n2>GB’ -f ($len / 1Gb)
>
% is an alias for the foreach-object cycle.
Let’s go on. Suppose, your task is to find the size of each directory in the root of the system hard drive and present the information in the convenient table form for analysis and able to be sorted by the folder size. To do it, let’s use the Out-GridView cmdlet.
To get the information about the size of directories on the drive C:\, run the following PowerShell script:
$targetfolder=’C:\’
$dataColl = @()
gci -force $targetfolder -ErrorAction SilentlyContinue | ? < $_ -is [io.directoryinfo] >| % <
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % < $len += $_.length >
$foldername = $_.fullname
$foldersize= ‘<0:n2>‘ -f ($len / 1Gb)
$dataObject = New-Object PSObject
Add-Member -inputObject $dataObject -memberType NoteProperty -name “foldername” -value $foldername
Add-Member -inputObject $dataObject -memberType NoteProperty -name “foldersizeGb” -value $foldersize
$dataColl += $dataObject
>
$dataColl | Out-GridView -Title “Size of subdirectories”
As you can see, the graphic view of the table should appear where all folders in the root of the system drive C:\ and their size are shown. By clicking the column header, you can sort the folders by size.