统计文件或文件夹大小

#列出一个文件夹下所有文件的信息
Get-ChildItem -Path F:\BCP -Recurse | Where-Object {$_.mode -Like "-*"} | Select-Object -Property FullName, Length | Export-Csv -Path "f:\file list.csv" -Encoding UTF8

#列出一个文件夹下所有temp文件夹的大小
$allfolder = Get-ChildItem -Path F:\BCP -Recurse | Where-Object {$_.Mode -Like "d*" -and $_.Name -eq "temp"} | select -Property Fullname
ForEach($folder in $allfolder) {
    $foldermeasure = Get-ChildItem -Path $folder.FullName | Measure-Object -Property length -Sum
    $folder.FullName + ',' + [System.Math]::Round($foldermeasure.Sum / 1048576) | Out-File -FilePath "f:\file list.csv" -Append -Encoding ascii
}

 

posted @ 2015-05-11 09:31  dongdonggeorge  阅读(282)  评论(0编辑  收藏  举报