首页 > 其他 > 详细

計量文件夾大小

时间:2019-12-21 21:11:36      阅读:99      评论:0      收藏:0      [点我收藏+]
##Using .com objects
function DirWithSize ($path=$PWD)
{
    $fs=New-Object -com scripting.filesystemobject
    Get-ChildItem $path|Format-Table -AutoSize Mode,LastWriteTime,Name,
    @{ Label="Lenght(KB)";alignment="Left";Expression={
        if($_.PSIsContainer){$fs.GetFolder($_.Fullname).Size/1KB}
        else
            {$_.length/1KB}
        }
    }
}
##Using measure count
function DirWithSize ($path=$pwd)
{
    ls $path |ft -au mode,lastwritetime,name,
    @{ Label="lenght(kb)";alignment="left";Expression={
        if($_.PsIsContainer){(ls $_.fullname -r -file|measure length -Sum).sum/1Kb}
        else
          {$_.length/1KB}
        }
    }
}

計量文件夾大小

原文:https://www.cnblogs.com/feiyucha/p/12078143.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!