user19451: How can I use pgn-extract to remove a game from a pgn file when there is an illegal move?

user12951: 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.

19451: <p>How can I use pgn-extract to remove a game from a pgn file when there is an illegal move?</p>
 12951: <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>
