Skip to content

Instantly share code, notes, and snippets.

@irwins
Last active March 9, 2016 08:41
Show Gist options
  • Save irwins/e5a579325e28d0070a7b to your computer and use it in GitHub Desktop.
Save irwins/e5a579325e28d0070a7b to your computer and use it in GitHub Desktop.
#region Define regex results
[regex]$whiteWin = '\[Result "1-0"\]'
[regex]$blackWin = '\[Result "0-1"\]'
[regex]$Tie = '\[Result "1/2-1/2"\]'
#endregion
#region Main Process All pgn files
Get-ChildItem -Path C:\Users\Irwin\Downloads\ChessData-master\ChessData-master -File *.pgn -Recurse |
ForEach-Object {
$pgnFile = Get-Content $_.FullName -Raw
[PSCustomObject]@{
FileReference = $_.Name
WhiteWin = ($whiteWin.Matches($pgnFile)).Count
BlackWin = ($blackWin.Matches($pgnFile)).Count
Tie = ($Tie.Matches($pgnFile)).Count
}
} |
Export-Csv .\export\ChessMatchesResults.csv -Delimiter "`t" -NoTypeInformation
#endregion
@irwins
Copy link
Author

irwins commented Mar 4, 2016

C:\scripts> Measure-Command { .\ps1\misc\Get-ChessMatchesResults.ps1 }

Days : 0
Hours : 0
Minutes : 3
Seconds : 53
Milliseconds : 31
Ticks : 2330310183
TotalDays : 0.00269711826736111
TotalHours : 0.0647308384166667
TotalMinutes : 3.883850305
TotalSeconds : 233.0310183
TotalMilliseconds : 233031.0183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment