One liner PowerShell for getting directory size (in GB)

Community for Programmers and Developers. C, C++, C#, Basic, Perl, VB, VBS, Java, Javascript, PHP, CGI, HTML and More!
• If you are posting source code, proper indenting and comments will improve the readability.

One liner PowerShell for getting directory size (in GB)

New postby 3ICE on Wed Dec 28, 2016 6:21 pm

Code: Select all
'{0:0.0} GiB' -f (((Get-ChildItem -Recurse | Measure-Object -Sum Length).Sum) / 1GB)

Shortest form:
Code: Select all
'{0:0.0} GiB' -f (((ls -r | measure -s Length).Sum) / 1GB)


In action:
One liner PowerShell for getting directory size (in GB).png
One liner PowerShell for getting directory size (in GB).png (5.35 KiB) Viewed 387 times

(Shows 1.7 GB, which is correct.)
ImageImageImageImageImage
Image
ImageImage
User avatar
3ICE
Admin
 
Posts: 2114
Joined: Sat Mar 01, 2008 11:34 pm
Location: Hungary
Realm: US East
Account: 3ICE
Clan: 3ICE

Return to Programming



Who is online

Users browsing this forum: No registered users and 3 guests