获取 windows 中文件夹大小的命令或工具,而不是使用 dir 或 du

Command or tools to get the folder size in windows other than using dir or du

我在一家软件公司工作。我已经使用批处理文件使用 dir 和 du 获取文件夹大小,但是 dir 需要 1 秒,du 需要 600 毫秒才能计算出 5GB 的文件夹大小。但我希望它对产品来说更快。那么是否有任何支持命令行的命令或工具可以更快地执行任务?命令可以是任何类型(bat、vbs、powershell....)

提前致谢....

电源shell解。

https://technet.microsoft.com/en-us/library/ff730945.aspx

阅读更多内容
$colItems = (Get-ChildItem C:\temp -Recurse | Measure-Object -Property length -Sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB" 

措施:

PS C:\> Measure-Command -Expression {
$colItems = (Get-ChildItem C:\temp -Recurse | Measure-Object -Property length -Sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB" 
}


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 509
Ticks             : 25092400
TotalDays         : 2,90421296296296E-05
TotalHours        : 0,000697011111111111
TotalMinutes      : 0,0418206666666667
TotalSeconds      : 2,50924
TotalMilliseconds : 2509,24

与 shell com 对象相同:

$objFSO = New-Object -ComObject  Scripting.FileSystemObject
"{0:N2}" -f (($objFSO.GetFolder("C:\temp").Size) / 1MB) + " MB"

措施:

PS C:\> Measure-Command -Expression {
$objFSO = New-Object -ComObject  Scripting.FileSystemObject
"{0:N2}" -f (($objFSO.GetFolder("C:\temp").Size) / 1MB) + " MB"
}


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 719
Ticks             : 7197995
TotalDays         : 8,33101273148148E-06
TotalHours        : 0,000199944305555556
TotalMinutes      : 0,0119966583333333
TotalSeconds      : 0,7197995
TotalMilliseconds : 719,7995