[CmdletBinding()] | |
Param ( | |
[ValidateScript({ Test-Path $_ } )] | |
[string]$Path = "c:\Test" | |
) | |
$ResultHash = @{ | |
"1-0" = 0 | |
"0-1" = 0 | |
"1/2-1/2" = 0 | |
} | |
$DisplayHash = @{ | |
"1-0" = "White" | |
"0-1" = "Black" | |
"1/2-1/2" = "Draw" | |
} | |
$Start = Get-Date | |
$Results = ForEach ($Dir in (Get-ChildItem $Path -Directory | Sort Name | Select -First 10)) | |
{ | |
ForEach ($File in (Get-ChildItem "$($Dir.FullName)\*.pgn" -File)) | |
{ | |
$RawFile = (New-Object System.IO.StreamReader -Argument $File.FullName).ReadToEnd() | |
ForEach ($Group in ($RawFile | Select-String -AllMatches -Pattern '\[Result \"(.*)\"').Matches) | |
{ | |
$ResultHash[$Group.Groups[1].Value] ++ | |
} | |
} | |
} | |
$ResultHash.Keys | Where { $_ -ne "*" } | Sort | Select @{Name="Winner";Expression={ $DisplayHash[$_] }},@{Name="Count";Expression={ $ResultHash[$_] }} | |
Write-Verbose $(New-TimeSpan -Start $Start -End (Get-Date)) -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
First run was 4 minutes 20 seconds (did screen shot that one). Second run was even better!
