Answers.Body: <p><a href="https://www.cs.kent.ac.uk/~djb/pgn-extract/" rel="noreferrer">pgn-extract</a> will do exactly that if you give it an input file and say where you want the correct games to go. For instance:</p>
  
  <pre><code>pgn-extract --output clean.pgn games.pgn
  </code></pre>
  
  <p>will put only the valid games from <code>games.pgn</code> into <code>clean.pgn</code>, reporting any errors on standard output. If you want to have a record of the errors then you can use the -l flag to specify a log file; e.g.:</p>
  
  <pre><code>pgn-extract --output clean.pgn -lissues.txt games.pgn
  </code></pre>
  
  <p>There are lots of additional options/flags described in <a href="https://www.cs.kent.ac.uk/~djb/pgn-extract/help.html" rel="noreferrer">the documentation</a>.</p>
  
  <p>Disclosure: I am the author of pgn-extract.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-02T05:38:33.790Z
Answers.LastActivityDate: 2019-07-02T05:38:33.790Z
Answers.UserDisplayName: kentdjb
Body: <p>How can I use pgn-extract to remove a game from a pgn file when there is an illegal move?</p>
  
Tags: <illegal-move>
Title: How can I use pgn-extract to remove a game from a pgn file when there is an illegal move?
ThreadText: # How can I use pgn-extract to remove a game from a pgn file when there is an illegal move?
  
  (Asked by: username_0 on 2019-07-01)
  
  How can I use pgn-extract to remove a game from a pgn file when there is an illegal move?
  
  **Tags:** illegal-move
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-07-02. Score: 8
  
  pgn-extract will do exactly that if you give it an input file and say where you want the correct games to go. For instance:
  pgn-extract --output clean.pgn games.pgn
  
  will put only the valid games from games.pgn into clean.pgn, reporting any errors on standard output. If you want to have a record of the errors then you can use the -l flag to specify a log file; e.g.:
  pgn-extract --output clean.pgn -lissues.txt games.pgn
  
  There are lots of additional options/flags described in the documentation.
  Disclosure: I am the author of pgn-extract.
  
  
  ---
  
  