How can I check the size of a folder from the Windows command line?
You will want to use dir /a/s
so that it includes every file, including system and hidden files. This will give you the total size you desire.
You can use PowerShell!
$totalsize = [long]0
Get-ChildItem -File -Recurse -Force -ErrorAction SilentlyContinue | % {$totalsize += $_.Length}
$totalsize
This recurses through the entire current directory (ignoring directories that can't be entered) and sums up the sizes of each file. Then it prints the total size in bytes.
Compacted one-liner:
$totalsize=[long]0;gci -File -r -fo -ea Silent|%{$totalsize+=$_.Length};$totalsize
On my machine, this seems slightly faster than a dir /s /a
, since it doesn't print each object's information to the screen.
To run it from a normal command prompt:
powershell -command "$totalsize=[long]0;gci -File -r -fo -ea Silent|%{$totalsize+=$_.Length};$totalsize"
There is no such command built into DOS or Windows Command Line. On Linux, there’s the du
(Disk Usage) command.
Microsoft’s Sysinternals line of tools has a tool that is roughly equivalent to du
on Linux. It’s also called du
. ;)