I added the DisplayInBytes ($ num) function to Bill Stewart's script "d.ps1"
function DisplayInBytes($num) { $suffix = "oct", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib" $index = 0 while ($num -gt 1kb) { $num = $num / 1kb $index++ } $sFmt="{0:N" if ($index -eq 0) {$sFmt += "0"} else {$sFmt += "1"} $sFmt += "} {1}" $sFmt -f $num, $suffix[$index] }
Replace block
# Create the formatted string expression. $formatStr = "'"{0,5} {1,10} {2,5} {3,15:N0} ({4,11})" $formatStr += iif { -not $Q } { " {5}" } { " {5,-22} {6}" } $formatStr += "'" -f '$_.Mode," + "'$_.$TimeField.ToString('d')," + "'$_.$TimeField.ToString('t')," + "'$_.Length,'$sfSize"
AND
if (-not $Bare) { $sfSize=DisplayInBytes $_.Length invoke-expression $formatStr
And in the end
# Output footer information when not using -bare. if (-not $Bare) { if (($fileCount -gt 0) -or ($dirCount -gt 0)) { $sfSize = DisplayInBytes $sizeTotal "{0,14:N0} file(s) {1,15:N0} ({3,11})'n{2,15:N0} dir(s)" -f $fileCount,$sizeTotal,$dirCount,$sfSize } }
Pci-l
source share