Powershell:遍历文件夹大小 发表于 2020-06-18 分类于 Windows 阅读次数: 本文字数: 398 阅读时长 ≈ 1 分钟 1234567891011121314151617function filesize ([string]$filepath){ if($filepath -eq $null){ throw "null path" } dir -Path $filepath | ForEach-Object -Process{ if($_.psiscontainer -eq $true){ $length=0 dir -Path $_.fullname -Recurse | ForEach-Object{ $length+=$_.length } $l=$length/1GB $_.name+" size is : {0:n3} GB" -f $l } }}filesize -filepath "C:\" 本文作者: LuHengXing 本文链接: http://www.dbapub.cn/2020/06/18/Powershell-%E9%81%8D%E5%8E%86%E6%96%87%E4%BB%B6%E5%A4%B9%E5%A4%A7%E5%B0%8F/ 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!