$enc = [ Text.Encoding]::GetEncoding( "Shift_JIS") function parse ($file){ $file -cmatch "([^\\]*)Test.java$" > $null $class = $matches[ 1] $fh = New-Object System.IO.StreamReader($file , $enc ) $status = 0; $type = ""; $method = ""; $ok = 0; $ng = 0; $sum = 0; while (($l = $fh.ReadLine()) -ne $null ) { switch ($status ){ 0 { if ($l -cmatch "^\s*/\*\*"){ $type = "" $method = ""; $status = 1; } } 1 { if ($l -cmatch "^\s*/\*\*"){ $status = 1; } elseif ($l -cmatch "\ *@auther *([^\s]*)"){ $type = $matches[ 1]; } elseif ($l -cmatch "^\s*\*/"){ $status = 2; } } 2 { if ($l -cmatch "^\s*/\*\*"){ $status = 1; } elseif ($l -cmatch "^\s*@Test"){ $status = 3; } } 3 { if ($l -cmatch "^\s*/\*\*"){ $status = 1; } elseif ($l -cmatch "^\s*public *void *(\w*)" ){ if ($type -eq "3i"){ $ok++ } elseif ($type -eq "Ui"){ $ng++ } $sum++; $method = $matches[ 1]; Write-Host " $class`t$method `t$type" $status = 0; } } } } $fh.Close(); Write-Host " $class`t$ok `t$ng`t $sum" } #$txt = "C:\yuji\work\20160628_powershell\FooTest.java" #parse $txt $path = "." if ($args .length -gt 0){ $path = $args[ 0]; } ls -r "${path} \*Test.java" | %{ parse $_ }