title: Multiple do commands in a for loop: Echoing a string to a file and then redirecting to the command window
body: <p>I am trying to write a  batch file to iteratively execute a fortran compiled executable. Normally one would go to the windows command prompt, type 'Model.exe'. This would bring up a dos command window asking the user to type a required file name directly in to the command window at the dos prompt. </p>
  
  <p>I want to write a batch file that will do this bit for me, and also iterate this step so that I can run 10 simulations consecutively instead of having to do it by hand. This kind of shell operation would be straightforward in linux, but I do not have this available.</p>
  
  <p>My pseudo code would look like this:</p>
  
  <p><em>for /L %%run in (1,1,10) do<br>
  (set str=Sim%%run<br>
  echo.%str% > input.txt<br>
  Model.exe &lt; input.txt)</em></p>
  
  <p>You could break this down in to the following steps: </p>
  
  <ol>
  <li>Assign variable 'run' a value. (e.g. 1)</li>
  <li>Concatenate this with a string ("Sim") to make a new variable, "Sim1"</li>
  <li>echo this to a text file ("input.txt")</li>
  <li>Read the variable "Sim1" from file "input.txt"</li>
  <li>Executable goes away and does its thing.</li>
  <li>Repeat steps 1 -> 5, but with a new variable calle "Sim2" etc.</li>
  </ol>
  
  <p>I can get the above to work if I use <em>set str=Sim1</em> and then echo this directly to "input.txt", but I cannot get this to work as a loop. Am I missing something?</p>
  
  <p>Best regards,</p>
  
  <p>Ben</p>