title: How to access an environment variable in a FOR loop set in same FOR loop?
body: <p>This is what I have:</p>
  
  <pre><code>FOR /f %%G IN (school\students\%studentname%\classes.txt) DO (
      set /p grade=&lt;"school\students\%studentname%\classes\%%G\grade.txt"
      pause
      echo %grade%
      echo You Have %grade% in %%G
  )
  pause
  </code></pre>
  
  <p>My problem is that I get back:</p>
  
  <pre><code>You have  in Math.
  You have  in English.
  </code></pre>
  
  <p>In the grade.txt files I have an A in one and a B in the other. The %%G is set to English and Math throughout the FOR command and find the folders fine. But the %grade% variable is not setting for some reason. I cannot figure out why. Thanks</p>