Answers.Body: <p>I looked at <a href="https://github.com/permutationlock/merge-pgn" rel="nofollow noreferrer">the merge-pgn tool</a> and made some modifications to it to have support for also merging text comments and also software comments/annotation (arrows and circles etc). There are some technical caveats but it works. <a href="https://github.com/olleeriksson/merge-pgn" rel="nofollow noreferrer">The modified version is available here</a>.</p>
  <p>For those who can't be bothered to install Python, and who doesn't have Chessbase, <a href="https://chesstempo.com" rel="nofollow noreferrer">chesstempo</a> is another free tool that also does real PGN game merging, but there are some issues with that.</p>
  <p>In order to get a clean merge, you have to remove all existing repertoires and reload the page before uploading the PGN files to merge, and then export them. If you are already using the opening trainer at chesstempo.com you would have to first export/backup your repertoires and then re-upload them afterwards which could be a nuisance. Also, while it does merge the text comments, it doesn't really merge the annotations (arrows and circles), and it will also include annotations from repertoires of the opposite color (hence the reason why you need to remove all repertoires before you begin). There is a discussion regarding these subtleties at <a href="https://old.chesstempo.com/chess-forum/help_and_support/any_way_to_delete_cal_comments_from_repertoire-t11246.0.html;msg76376#msg76376" rel="nofollow noreferrer">the site's forum</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-08T13:32:20.520Z
Answers.LastActivityDate: 2023-01-08T14:59:13.867Z
Answers.LastEditDate: 2023-01-08T14:59:13.867Z
Answers.UserDisplayName: Olle Eriksson
Answers.Body: <p>A piece of code that works perfectly for merging pgns is.</p>
  <p><a href="https://github.com/permutationlock/merge-pgn" rel="nofollow noreferrer">https://github.com/permutationlock/merge-pgn</a></p>
  <p>The code is not regex heavy, thanks to python-chess library. It can merge several pgn games into a single pgn with one game including all moves as variations.</p>
  <p>All headers and comments are ignored as this is designed only to manipulate the move lines.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-18T06:30:05.577Z
Answers.LastActivityDate: 2021-05-18T06:30:05.577Z
Answers.UserDisplayName: abunickabhi
Body: <p>Merging two pgn files is an operation, that makes just one game variation, and the one of the game gets added as a variation to the other game. If both the games have similar opening, then the similar opening moves are eliminated and a variation is created at the point when both the games starts to differ.</p>
  <p>In Chessbase software (or any other chess tools), it is easy to merge normal chess games, we just copy the game and paste it into another, and it gets added as a variation. If if we have to do this for multiple games, it get laborious and manual process of merging. It will be good if some automated script exists for this purpose.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-21T12:29:00.710Z
Comments.Text: I know Im nitpicking but to me merging files is a different thing than merging the games from 2 pgn files into one game
Comments.UserDisplayName: Purefan
Tags: <pgn>
Title: How to merge multiple pgn files?
ThreadText: # How to merge multiple pgn files?
  
  (Asked by: username_0 on 2021-05-18)
  
  Merging two pgn files is an operation, that makes just one game variation, and the one of the game gets added as a variation to the other game. If both the games have similar opening, then the similar opening moves are eliminated and a variation is created at the point when both the games starts to differ.
  
  In Chessbase software (or any other chess tools), it is easy to merge normal chess games, we just copy the game and paste it into another, and it gets added as a variation. If if we have to do this for multiple games, it get laborious and manual process of merging. It will be good if some automated script exists for this purpose.
  
  **Tags:** pgn
  
  > **Comments:**
  > **username_1**: I know Im nitpicking but to me merging files is a different thing than merging the games from 2 pgn files into one game  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2023-01-08. Score: 3
  
  I looked at [the merge-pgn tool](https://github.com/permutationlock/merge-pgn) and made some modifications to it to have support for also merging text comments and also software comments/annotation (arrows and circles etc). There are some technical caveats but it works. [The modified version is available here](https://github.com/username_2/merge-pgn).
  
  For those who can't be bothered to install Python, and who doesn't have Chessbase, [chesstempo](https://chesstempo.com) is another free tool that also does real PGN game merging, but there are some issues with that.
  
  In order to get a clean merge, you have to remove all existing repertoires and reload the page before uploading the PGN files to merge, and then export them. If you are already using the opening trainer at chesstempo.com you would have to first export/backup your repertoires and then re-upload them afterwards which could be a nuisance. Also, while it does merge the text comments, it doesn't really merge the annotations (arrows and circles), and it will also include annotations from repertoires of the opposite color (hence the reason why you need to remove all repertoires before you begin). There is a discussion regarding these subtleties at [the site's forum](https://old.chesstempo.com/chess-forum/help_and_support/any_way_to_delete_cal_comments_from_repertoire-t11246.0.html;msg76376#msg76376).
  
  
  ---
  
  ### Answer by username_0 on 2021-05-18. Score: 3
  
  A piece of code that works perfectly for merging pgns is.
  
  <https://github.com/permutationlock/merge-pgn>
  
  The code is not regex heavy, thanks to python-chess library. It can merge several pgn games into a single pgn with one game including all moves as variations.
  
  All headers and comments are ignored as this is designed only to manipulate the move lines.
  
  
  ---
  
  