用PowerShell来计算代码的大小和行数

这里是两段脚本来计算代码的大小和行数。

代码大小(MB):
(Get-ChildItem . -Recurse | Where-Object {(!$_.PSIsContainer) -And ($_.FullName -Match '\.(h|m|cpp|c|cs|y)$')} | Measure-Object -Property Length -Sum).Sum / 1MB

代码行数:
Get-ChildItem . -Recurse | Where-Object {(!$_.PSIsContainer) -And ($_.FullName –Match '\.(h|m|cpp|c|cs|y)$')} | ForEach-Object {$l = 0} {$l += (Get-Content $_.PSPath).Count} {$l}

posted @ 2010-10-25 12:10  夜深沉  阅读(486)  评论(0)    收藏  举报