title: Prevent extra whitespace when piping data in a Windows batch script
body: <p>I have to run an executable (written in C#) 42 times separately for 42 US states on Windows command line. I wrote a batch file to automate the process. The 1st user input to the executable is 1, and the 2nd one is the state abbreviation (AL, AZ, CT etc.). I have written the following script to do it:</p>
  
  <pre><code>@echo off
  
  for /f "tokens=1 delims=" %%x in (CropHailStates.txt) do (
  
      (echo 1 &amp; echo %%x)|Z:\Models\LossCalc.exe 
  )
  </code></pre>
  
  <p>Each row in CropHailStates.txt file contains the state abbreviation as follows:</p>
  
  <p>AL</p>
  
  <p>AZ</p>
  
  <p>CT</p>
  
  <p>Now in manual mode, when 1 is entered at the 1st prompt and AL is entered at the 2nd, the C# program reads a file named "AL.Even.CropLoss.csv". But when I run the batch script to do it automatically, I get the error message saying that the file "AL .Even.CropLoss.csv" is not found. The problem is related to the extra whitespace after AL. It’s somehow adding the whitespace after inserting the state abbreviation. It’s like pressing the spacebar after writing the state abbreviation, but before pressing enter.</p>
  
  <p>How can I get rid of that extra whitespace in the file name?</p>