亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Powershell 之批量獲取文件大小的實現(xiàn)代碼

 更新時間:2016年11月27日 20:54:23   投稿:mdxy-dxy  
這篇文章主要介紹了Powershell 之批量獲取文件大小的實現(xiàn)代碼,需要的朋友可以參考下

效果圖:

核心代碼

$startFolder = "D:\"
$colItems = (Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)
foreach ($i in $colItems)
{
 $subFolderItems = (Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum)
 $FileSize="{0:N2}" -f ($subFolderItems.sum / 1GB)
 $Unit='GB'
 if($FileSize -lt 1)
 {
  $FileSize="{0:N2}" -f ($subFolderItems.sum / 1MB)
  $Unit='MB'
 }
 write-host $i.FullName ' -- ' $FileSize $Unit -fore green
}

注意:如果是第一次運行需要開啟執(zhí)行腳本權限。

在powershell中運行如下命令,然后 Y 確認即可。

開啟:set-executionpolicy remotesigned

關閉:Set-ExecutionPolicy Restricted

相關文章

最新評論