title: Read the first word on a specific line from a text file using batch script then feed into an if statement
body: <p>Sorry I know similar things have been asked here but basically I'm trying to read a text file within a batch script and evaluate what has been written to the file.</p>
  
  <p>The job is a print job that sends a file to a printer, I have it echoing the output from the command to a log file.  I then want to read in what the output was and if there was an error I will then send an email so we know when things stop working.</p>
  
  <p>It always appends to the end of the file so I know if there's an error the 4th from last line will begin with "Error:".  So my question is how can I read that in to a variable so I can perform an IF statement.  I've got the emailing part sorted it's just reading from the file that I'm struggling with.</p>
  
  <p>Any help would be much appreciated.  Here's an example of the content of the file when there's an error:</p>
  
  <pre><code>---- 
  C:\XG1\DGS01\prints\000000398200001.XG1 
  19/03/2013 
  15:02
          1 file(s) copied.
  Error: print server unreachable or specified printer does not exist.
  
          1 file(s) moved.
  </code></pre>
  
  <p>It leaves one blank line at the end of the file so I'm going with the last line minus 4.</p>
  
  <p>Thank you</p>