Friday, December 27, 2019

Report total data size in current Windows 10 folder

My successful one-liner in PowerShell is:

"{0:N2} GB" -f ((Get-ChildItem . -recurse | measure Length -s).sum/1Gb)

I saw this post to derive above successful one.

http://woshub.com/powershell-get-folder-sizes/
The commands shown above allow you to get only the total size of files in the specified directory. If there are subfolders in the directory, the size of files in the subfolders won’t be calculated. To get the total size of files in the directory taking subfolders into account, use the –Recurse parameter. Let’s get the total size of files in the C:\Windows directory:
"{0:N2} GB" -f ((gci –force c:\Windows –Recurse -ErrorAction SilentlyContinue| measure Length -s).sum / 1Gb)

No comments:

Post a Comment