user5770: Is there a way to read a PGN file using the Stockfish engine? If so, please give a sample command.

user27555: You can use 2 programs to do that.

Use pgn-extract to format the pgn files in a good format. This pgn-extract is available at this url: download pgn-extract
You need this CLI tool: UCI analyzer
Lastly, you need a chess engine that supports UCI installed, such as Stockfish.

I used these tools to perform a massive analysis of 2 million games on multiple machines.

user825: No. Stockfish is an engine not GUI, it doesn't know or understand PGN. The bigger problem is why would you do that? Why would you want to use an engine on a PGN game? This is like giving a calculator your math exam and hope it'll give out answers magically. Please rethink why you would want to do this.

user7281: The answer is NO. The stockfish engine does not have a concept of a chessboard state. Each position should be completely described through FEN notation. If you want to make a move, you then again describe the complete position and append your moves all in one command string then press ENTER on the keyboard. The engine does not remember the current position for you. 

user19915: Stockfish is an engine that's called by apps that read PGN files, it doesn't read the PGN data itself. 
There are many very good free apps that can read PGN files and analyse the games they contain using Stockfish (which is also free) and/or similar engines (mostly not free)
A lot of good free PGN reader apps that are able to call Stockfish can be downloaded and installed from SourceForge, such as
ChessX An old app but a good one
Scid The most popular app on SourceForge at the time of writing
PGN ChessBook Which comes with the requested Stockfish engine built in
If you search for "pgn" on SourceForge you should find more apps, but in my opinion these are the best ones currently available.

5770: <p>Is there a way to read a PGN file using the Stockfish engine? If so, please give a sample command.</p>
 27555: <p>You can use 2 programs to do that.</p>
<ol>
<li>Use pgn-extract to format the pgn files in a good format. This pgn-extract is available at this url: <a href="https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/" rel="nofollow noreferrer">download pgn-extract</a></li>
<li>You need this CLI tool: <a href="https://www.cs.kent.ac.uk/people/staff/djb/uci-analyser/" rel="nofollow noreferrer">UCI analyzer</a></li>
<li>Lastly, you need a chess engine that supports UCI installed, such as Stockfish.</li>
</ol>
<p>I used these tools to perform a massive analysis of 2 million games on multiple machines.</p>
 825: <p>No. Stockfish is an engine not GUI, it doesn't know or understand PGN. The bigger problem is why would you do that? Why would you want to use an engine on a PGN game? This is like giving a calculator your math exam and hope it'll give out answers magically. Please rethink why you would want to do this.</p>
 7281: <p>The answer is NO. The stockfish engine does not have a concept of a chessboard state. Each position should be completely described through FEN notation. If you want to make a move, you then again describe the complete position and append your moves all in one command string then press ENTER on the keyboard. The engine does not remember the current position for you. </p>
 19915: <p>Stockfish is an engine that's called by apps that read PGN files, it doesn't read the PGN data itself. </p>

<p>There are many very good free apps that can read PGN files and analyse the games they contain using Stockfish (which is also free) and/or similar engines (mostly not free)</p>

<p>A lot of good free PGN reader apps that are able to call Stockfish can be downloaded and installed from SourceForge, such as</p>

<p><a href="https://sourceforge.net/projects/chessx/" rel="noreferrer">ChessX</a> An old app but a good one</p>

<p><a href="https://sourceforge.net/projects/scid/" rel="noreferrer">Scid</a> The most popular app on SourceForge at the time of writing</p>

<p><a href="https://sourceforge.net/projects/pgn-chessbook/" rel="noreferrer">PGN ChessBook</a> Which comes with the requested Stockfish engine built in</p>

<p>If you search for "pgn" on SourceForge you should find more apps, but in my opinion these are the best ones currently available.</p>
