function filesize ([string]$filepath) { if ($filepath -eq $null) { throw "路径不能为空" } $hash_size[email protected]{} dir -Path $filepath | ForEach-Object -Process { if ($_.psiscontainer -eq $true) { $length = 0 dir -Path $_.fullname -Recurse | ForEach-Object{ $length += $_.Length } $l = $length/1MB [int]$FolderSIZE=" {0:n1}" -f $l $hash_size.($_.name)=$FolderSIZE } } $hash_size.GetEnumerator() | Sort-Object Value } filesize -filepath ".\"
时间: 2024-11-03 05:33:19