Awesome CMD One-Liner to Know The Disk Usage Status

Windows Management Instrumentation Command-Line (WMIC) is the Windows most powerful secret weapon very few are aware of. Though supplanted by cmd and PowerShell lately, using WMIC we can accomplish amazing things. For instance, to know how much of disk space is filled and how much is left in a partition, we can run the following one-liner:

for /f "tokens=1-3" %a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"') do @echo wsh.echo "%b" ^& " free=" ^& FormatNumber^(cdbl^(%a^)/1024/1024/1024, 2^)^& " GiB"^& " size=" ^& FormatNumber^(cdbl^(%c^)/1024/1024/1024, 2^)^& " GiB" > %temp%\tmp.vbs & @if not "%c"=="" @echo( & @cscript //nologo %temp%\tmp.vbs & del %temp%\tmp.vbs

windows-wizardry-disk-space-wmic-oneliner