Last active
December 21, 2019 22:47
-
-
Save yeahservice/d43cd561ff15cae9f39a86ab28b6de55 to your computer and use it in GitHub Desktop.
Windows Powershell script for displaying directory sizes. Just copy it into the root directory and execute the script with Powershell.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -Directory | ForEach-Object { | |
"$_" | |
cd $_ | |
switch((ls -r|measure -s Length).Sum) { | |
{$_ -gt 1GB} { | |
'{0:0.0} GB' -f ($_/1GB) | |
break | |
} | |
{$_ -gt 1MB} { | |
'{0:0.0} MB' -f ($_/1MB) | |
break | |
} | |
{$_ -gt 1KB} { | |
'{0:0.0} KB' -f ($_/1KB) | |
break | |
} | |
default { "$_ bytes" } | |
} | |
cd .. | |
"" | |
} | |
Read-Host -Prompt "Press any key to exit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment