Instead of using Nushell's DU command, use the Sysinternals DU command
This function will use the Sysinternals DU comand and transpose the data and format the numbers with a separator and right align.
def du64x [dir: string] {
^'C:\Program Files\sysinter\DiskUsage\du64.exe' -nobanner -c $dir |
from csv |
transpose Item Value |
update Value {
|row|
if $row.Item in ["CurrentFileSize", "DirectorySize", "DirectorySizeOnDisk"] {
let size = ($row.Value | into int)
let formatted = match $size {
..<1_000 => $"($size) B",
..<1_000_000 => $"(($size / 1_000 | math round -p 2)) KB",
..<1_000_000_000 => $"(($size / 1_000_000 | math round -p 2)) MB",
..<1_000_000_000_000 => $"(($size / 1_000_000_000 | math round -p 2)) GB",
_ => $"(($size / 1_000_000_000_000 | math round -p 2)) TB"
}
$formatted | fill -a right -w 15 -c ' '
} else if $row.Item in ["CurrentFileCount", "FileCount", "DirectoryCount"] {
($row.Value | into int | into string -g) | fill -a right -w 15 -c ' '
} else {
$row.Value
}
}
}
du64 d:\work\nu
╭───┬─────────────────────┬─────────────────╮
│ # │ Item │ Value │
├───┼─────────────────────┼─────────────────┤
│ 0 │ Path │ d:\work\nu │
│ 1 │ CurrentFileCount │ 98 │
│ 2 │ CurrentFileSize │ 1.97 GB │
│ 3 │ FileCount │ 451 │
│ 4 │ DirectoryCount │ 12 │
│ 5 │ DirectorySize │ 2.7 GB │
│ 6 │ DirectorySizeOnDisk │ 2.71 GB │
╰───┴─────────────────────┴─────────────────╯
Nushell's DU command does not show the file count and directory count.
du d:/work/nu
╭───┬────────────┬──────────┬──────────╮
│ # │ path │ apparent │ physical │
├───┼────────────┼──────────┼──────────┤
│ 0 │ d:\work\nu │ 2.7 GB │ 2.7 GB │
╰───┴────────────┴──────────┴──────────╯