Building a pgn file

Discuss anything you like about chess related matters in this forum.
Roger de Coverly
Posts: 21322
Joined: Tue Apr 15, 2008 2:51 pm

Building a pgn file

Post by Roger de Coverly » Fri Nov 24, 2023 4:53 pm

The Kidlington Congress has an archive of games played in recent years

For example
https://kidlingtonchess.org.uk/games-2023/

These use the pgn4web software to display the games. If you click on c8, you get the pgn source for each individual game.

For example
[Event "44th KIDLINGTON CHESS TOURNAMENT Open Section"]
[Site "Exeter Hall, Oxford Road, Kidlington, Oxfordshire OX5 1AB"]
[Date "2023.02.04"]
[Round "1.1"]
[White "Hayward, Philip T"]
[Black "Harvey, Marcus R"]
[Result "0-1"]
[BlackElo "2540"]
[ECO "A10"]
[Opening "English"]
[Variation "1...b6 2.Nc3 Bb7 3.e4 e6"]
[WhiteElo "2049"]
[TimeControl "300"]
[Termination "normal"]
[PlyCount "67"]
[WhiteType "human"]
[BlackType "human"]

1. c4 b6 2. Nc3 Bb7 3. e4 e6 4. Nge2 Nf6 5. d3 h5 6. h4 c5 7. g3 Be7 8. Bg2 Nc6 9. O-O Ng4 10. Nf4 Nce5 11. Nh3 d6 12. b3 Bf6 13. Bb2 Nc6 14. Qd2 Nd4 15. Ne2 Nxe2+ 16. Qxe2 Bxb2 17. Qxb2 O-O 18. d4 e5 19. d5 Bc8 20. Bf3 g6 21. Kg2 Qe7 22. Qd2 Kg7 23. Rae1 Bd7 24. Bd1 Rae8 25. Qg5 a6 26. Qxe7 Rxe7 27. Bxg4 hxg4 28. Ng1 b5 29. Ne2 Rb8 30. Rb1 f5 31. Nc3 Rf7 32. b4 cxb4 33. Rxb4 Rc8 34. Rfb1 Be8 35. Nxb5 axb5 36. cxb5 Ra7 37. b6 Rb7 38. a4 Kf8 39. a5 Ra8 40. Ra1 Ra6 41. Rbb1 Ke7 42. Rc1 fxe4 43. Rc6 Bf7 44. Rac1 Bxd5 45. Rc7+ Ke6 46. Rxb7 Bxb7 47. Rc7 e3+ 48. Kf1 Bf3 49. fxe3 Rxa5 50. b7 Rb5 0-1
If I wanted a consoldated pgn file of all the games, is there a shortcut? Obviously the long winded route is available, namely create a text file by pasting all the games into it.

Ian Thompson
Posts: 3561
Joined: Wed Jul 02, 2008 4:31 pm
Location: Awbridge, Hampshire

Re: Building a pgn file

Post by Ian Thompson » Fri Nov 24, 2023 5:01 pm

Roger de Coverly wrote:
Fri Nov 24, 2023 4:53 pm
If I wanted a consoldated pgn file of all the games, is there a shortcut? Obviously the long winded route is available, namely create a text file by pasting all the games into it.
Assuming you're using a Windows PC, put all the pgn files in one folder, open a command prompt, go to that folder and run

Code: Select all

copy *.pgn all-games.pgn

Roger de Coverly
Posts: 21322
Joined: Tue Apr 15, 2008 2:51 pm

Re: Building a pgn file

Post by Roger de Coverly » Fri Nov 24, 2023 5:08 pm

Ian Thompson wrote:
Fri Nov 24, 2023 5:01 pm
Assuming you're using a Windows PC, put all the pgn files in one folder, open a command prompt, go to that folder and run

Code: Select all

copy *.pgn all-games.pgn
That's using the old MSDOS method. The problem will remain in creating several hundred pgn files from the website, one for each game.

Colin Purdon
Posts: 67
Joined: Wed Mar 13, 2013 12:45 pm

Re: Building a pgn file

Post by Colin Purdon » Fri Nov 24, 2023 7:13 pm

Each pgn4web board has its pgn sourced as a text string (rather than from a single games database) so I can't see that there's a neat shortcut to get all the games in one go.

You could save the html page source (or just the games' pgns, which are close together in the html) and edit out the extraneous html, but I doubt that would be a quicker solution than the copy&paste option, unless I am underestimating your text manipulation skills with (eg) awk and sed.

Roger de Coverly
Posts: 21322
Joined: Tue Apr 15, 2008 2:51 pm

Re: Building a pgn file

Post by Roger de Coverly » Fri Nov 24, 2023 7:49 pm

Colin Purdon wrote:
Fri Nov 24, 2023 7:13 pm
Each pgn4web board has its pgn sourced as a text string (rather than from a single games database) so I can't see that there's a neat shortcut to get all the games in one go.
Clicking the square d8 is supposed to give the pgn of all the games, but it's only doing the same as clicking c8, namely the current game. I think it used to work at some time in the past. One file per round per tournament is manageable.

Colin Purdon
Posts: 67
Joined: Wed Mar 13, 2013 12:45 pm

Re: Building a pgn file

Post by Colin Purdon » Fri Nov 24, 2023 9:03 pm

Roger de Coverly wrote:
Fri Nov 24, 2023 7:49 pm
Clicking the square d8 is supposed to give the pgn of all the games, but it's only doing the same as clicking c8, namely the current game. I think it used to work at some time in the past. One file per round per tournament is manageable.
The d8 functionality still works if one pgn4web (or Embed Chessboard Plugin as it's known to Wordpress) board is used to display multiple games from a single pgn file. However, the Kidlington web site has chosen to use one board for one game. If you view the html source, you can see how it's configured.

(When I said "Each pgn4web board has its pgn sourced as a text string" I meant how it was used on the Kidlington site, I didn't mean to imply a limitation of the plugin.)