1

Is there a way to split large PGN files into folders grouped by the players? For example, in a tournament, each player has several games in one file. I aim to group each game by players to the respective folders (one game, one file). So it will produce two files for each match, one for player 1 and one for player 2 in two separate folders.

1 Answer 1

2

Either you may be able to do it in a DB manager (ChessBase...) or you'll need a bit of coding in Chess Query Language


Download and extract cqli (a modern rewrite of the original cql software) to the folder containing your pgn database

Create a p1.cql file, with the following content (this is an example for getting all Kasparov's games) :

cql(input database.pgn)

"Kasparov" in player

Open Powershell/Terminal (depending on your platform), cd to the database directory and run

Unix/Linux

./cqli --threads 8 p1.cql

macOS

# For Intel Macs
./cqli-x86_64 --threads 8 p1.cql
# For Apple Silicon Macs
./cqli-arm64 --threads 8 p1.cql

Windows

./cqli.exe --threads 8 p1.cql

And you'll find the resulting database in p1-out.pgn.

Note that it is a database, to extract it, we can use kentdjb pgn-extract

Unzip the windows executable in the database program as previously, or build it from source if you are on Linux/macOS

And then run :

./pgn-extract -\#1 p1-out.pgn

The backslash before the # is essential

This will split your pgn into files named 1.pgn, 2.pgn...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.