Answers.Body: <p>What I came up with was a google spreadsheet Substitute command to change the &quot;{}&quot; to &quot;[]&quot; and reordering the comment to a tag. If anyone has anything more elegant, let me know, but for file of just about 80 games, it did the trick without too much hassle.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-20T15:49:46.663Z
Answers.LastActivityDate: 2024-12-20T15:49:46.663Z
Answers.UserDisplayName: user43098
Body: <p>I've been using pgn-extract to compile a PGN file acting as a collection of opening positions. It has th ability to add the FEN of the final position to he end of each PGN, but for my purposes with this file, I need the FEN to be written as a header/tag.</p>
  <p>Current Result:</p>
  <pre><code>[Event &quot;N/A&quot;]
  [Site &quot;lichess.com&quot;]
  [Date &quot;&quot;]
  [Round &quot;N/A&quot;]
  [White &quot;N/A&quot;]
  [Black &quot;N/A&quot;]
  [Result &quot;*&quot;]
  
  1. d4 d5 2. c4 e6 3. Nf3 Nf6 4. g3 Be7 5. Bg2 O-O 6. O-O
  { &quot;rnbq1rk1/ppp1bppp/4pn2/3p4/2PP4/5NP1/PP2PPBP/RNBQ1RK1 b - - 4 6&quot; } *
  </code></pre>
  <p>Desired Result:</p>
  <pre><code>[Event &quot;N/A&quot;]
  [Site &quot;lichess.com&quot;]
  [Date &quot;&quot;]
  [Round &quot;N/A&quot;]
  [White &quot;N/A&quot;]
  [Black &quot;N/A&quot;]
  [Result &quot;*&quot;]
  [FEN&quot;FEN_STRING_HERE&quot;]
  </code></pre>
  <p>If anyone knows a way to add the FEN of the final position a multiple files/games at once to the heading using pgn-extract or something else, please let me know. Thanks.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-12-20T15:47:38.433Z
Comments.Text: A problem with that functionality is that a FEN tag in the header of a game is used to indicate the starting position for the game. So adding such a tag with the final position would invalidate the game.
Comments.UserDisplayName: kentdjb
Tags: <pgn><fen><pgn-extract>
Title: pgn-extract adding a FEN tag/header to each PGN
ThreadText: # pgn-extract adding a FEN tag/header to each PGN
  
  (Asked by: username_0 on 2024-12-20)
  
  I've been using pgn-extract to compile a PGN file acting as a collection of opening positions. It has th ability to add the FEN of the final position to he end of each PGN, but for my purposes with this file, I need the FEN to be written as a header/tag.
  Current Result:
  [Event "N/A"]
  [Site "lichess.com"]
  [Date ""]
  [Round "N/A"]
  [White "N/A"]
  [Black "N/A"]
  [Result "*"]
  
  1. d4 d5 2. c4 e6 3. Nf3 Nf6 4. g3 Be7 5. Bg2 O-O 6. O-O
  { "rnbq1rk1/ppp1bppp/4pn2/3p4/2PP4/5NP1/PP2PPBP/RNBQ1RK1 b - - 4 6" } *
  
  Desired Result:
  [Event "N/A"]
  [Site "lichess.com"]
  [Date ""]
  [Round "N/A"]
  [White "N/A"]
  [Black "N/A"]
  [Result "*"]
  [FEN"FEN_STRING_HERE"]
  
  If anyone knows a way to add the FEN of the final position a multiple files/games at once to the heading using pgn-extract or something else, please let me know. Thanks.
  
  **Tags:** pgn, fen, pgn-extract
  
  > **Comments:**
  > **username_1**: A problem with that functionality is that a FEN tag in the header of a game is used to indicate the starting position for the game. So adding such a tag with the final position would invalidate the game.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-12-20. Score: -1
  
  What I came up with was a google spreadsheet Substitute command to change the "{}" to "[]" and reordering the comment to a tag. If anyone has anything more elegant, let me know, but for file of just about 80 games, it did the trick without too much hassle.
  
  
  ---
  
  