PSFolderSize icon indicating copy to clipboard operation
PSFolderSize copied to clipboard

Include files in the list

Open generalerror404 opened this issue 4 years ago • 1 comments

The report is incomplete since it doesn't include the size of the files in $BasePath.

get all of the folder information , but do it for files in $BasePath

#Get folder info / sizes
$folderSize = Get-Childitem -Path $BasePath -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum -ErrorAction SilentlyContinue       
#We use the string format operator here to show only 2 decimals, and do some PS Math.
$folderSizeInMB = "{0:N2} " -f ($folderSize.Sum / 1MB)
$folderSizeInGB = "{0:N2} " -f ($folderSize.Sum / 1GB)

#Here we create a custom object that we'll add to the array
$folderObject = [PSCustomObject]@{
    FolderName    = '"files"'
    'Size(Bytes)' = $folderSize.Sum
    'Size(MB)'    = $folderSizeInMB
    'Size(GB)'    = $folderSizeInGB
}                        

#Add the object to the array
$folderList.Add($folderObject) | Out-Null

Thank you for a very useful tool.

generalerror404 avatar Jun 25 '21 15:06 generalerror404

Good morning! Glad the tool has been useful for you. I will be working on the two issues you have opened, and roll them into my next version release that includes the other open ones as well.

gngrninja avatar Jul 01 '21 15:07 gngrninja