title: Set variable equal to a number in a text file Batch
body: <p>I have a batch file (<code>tickets.bat</code>) and each time you create a different ticket, by setting multiple variables and echoing the variables to a text file, I want the ticket number to go up by 1. I tried to do this by creating a <code>number.txt</code> file and each time you go through the loop and create a new ticket, it sets <code>%pnumber%</code> to the text file, and then sets <code>%number%</code> to <code>%pnumber%</code> plus 1. But <code>%pnumber%</code> keeps setting to 0, even when the <code>number.txt</code> file contains the number 1 and doesn't change. This is what I have:</p>
  
  <pre><code>:start
  cls
  echo Enter Ticket Info Here:
  set /p name="Name:"
  echo Press Enter to Show Ticket Preview
  set /a pnumber=C:\Batch\ticket\number.txt
  set /a number=%pnumber%+1
  echo %number% &gt; "C:\Batch\ticket\number.txt"
  echo %name% Ticket Number %number%
  pause
  goto start
  </code></pre>
  
  <p>It looks like my problem is that <code>%pnumber%</code> always sets to 0. Unless I'm missing something else. Basically, I need it to always increase <code>%number%</code> by 1, even if you close the Batch job and open it up again, so that's why I went to using a <code>.txt</code> file. Is it not seeing the number in the text file or something? It's one number on one line. Thank you.</p>