Here, if you want to check the size of multiple folders, you can press Ctrl key and select all the folders. Then right-click and select Properties. In the pop-up folder properties window, you can see the total size of the selected folders.
Open a file explorer window and right-click on the 'Name' field at the top. You'll see some options – specifically, options, that let you pick what sort of info you want to see about your folders. Select Size and the property will appear on the far right of your window.
Right-click on the folder you want to view the size in File Explorer. Select “Properties.” The File Properties dialogue box will appear displaying the folder “Size” and its “Size on disk.” It will also show the file contents of those particular folders.
The du command displays the amount of file space used by the specified files or directories. If the specified path is a directory, du summarizes disk usage of each subdirectory in that directory.
There is a built-in Windows tool for that:
dir /s 'FolderName'
This will print a lot of unnecessary information but the end will be the folder size like this:
Total Files Listed:
12468 File(s) 182,236,556 bytes
If you need to include hidden folders add /a
.
You can just add up sizes recursively (the following is a batch file):
@echo off
set size=0
for /r %%x in (folder\*) do set /a size+=%%~zx
echo %size% Bytes
However, this has several problems because cmd
is limited to 32-bit signed integer arithmetic. So it will get sizes above 2 GiB wrong1. 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:
Get-ChildItem -Recurse | Measure-Object -Sum Length
or shorter:
ls -r | measure -sum Length
If you want it prettier:
switch((ls -r|measure -sum Length).Sum) {
{$_ -gt 1GB} {
'{0:0.0} GiB' -f ($_/1GB)
break
}
{$_ -gt 1MB} {
'{0:0.0} MiB' -f ($_/1MB)
break
}
{$_ -gt 1KB} {
'{0:0.0} KiB' -f ($_/1KB)
break
}
default { "$_ bytes" }
}
You can use this directly from cmd
:
powershell -noprofile -command "ls -r|measure -sum Length"
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 :-)
Oneliner:
powershell -command "$fso = new-object -com Scripting.FileSystemObject; gci -Directory | select @{l='Size'; e={$fso.GetFolder($_.FullName).Size}},FullName | sort Size -Descending | ft @{l='Size [MB]'; e={'{0:N2} ' -f ($_.Size / 1MB)}},FullName"
Same but Powershell only:
$fso = new-object -com Scripting.FileSystemObject
gci -Directory `
| select @{l='Size'; e={$fso.GetFolder($_.FullName).Size}},FullName `
| sort Size -Descending `
| ft @{l='Size [MB]'; e={'{0:N2} ' -f ($_.Size / 1MB)}},FullName
This should produce the following result:
Size [MB] FullName
--------- --------
580,08 C:\my\Tools\mongo
434,65 C:\my\Tools\Cmder
421,64 C:\my\Tools\mingw64
247,10 C:\my\Tools\dotnet-rc4
218,12 C:\my\Tools\ResharperCLT
200,44 C:\my\Tools\git
156,07 C:\my\Tools\dotnet
140,67 C:\my\Tools\vscode
97,33 C:\my\Tools\apache-jmeter-3.1
54,39 C:\my\Tools\mongoadmin
47,89 C:\my\Tools\Python27
35,22 C:\my\Tools\robomongo
I suggest to download utility DU from the Sysinternals Suite provided by Microsoft at this link http://technet.microsoft.com/en-us/sysinternals/bb896651
usage: du [-c] [-l <levels> | -n | -v] [-u] [-q] <directory>
-c Print output as CSV.
-l Specify subdirectory depth of information (default is all levels).
-n Do not recurse.
-q Quiet (no banner).
-u Count each instance of a hardlinked file.
-v Show size (in KB) of intermediate directories.
C:\SysInternals>du -n d:\temp
Du v1.4 - report directory disk usage
Copyright (C) 2005-2011 Mark Russinovich
Sysinternals - www.sysinternals.com
Files: 26
Directories: 14
Size: 28.873.005 bytes
Size on disk: 29.024.256 bytes
While you are at it, take a look at the other utilities. They are a life-saver for every Windows Professional
If you have git installed in your computer (getting more and more common) just open MINGW32 and type: du folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With