title: Remove space at the end of /F
body: <p>Hi there guys I'm trying to use the <code>FOR /F</code> command in batch file but I'm getting a problem.</p>
  
  <p>I run it....</p>
  
  <pre><code>rem finding model number
  for /F "delims= skip=1 tokens=*" %%a in ('wmic csproduct get name') do if not defined model set model=%%a
  </code></pre>
  
  <p>and it works well, I get the result I want </p>
  
  <pre><code>result: 637263G
  </code></pre>
  
  <p>Now lets say i create a folder called  "637263G" under c:\windows\</p>
  
  <pre><code>eg:c:\windows\637263G\test
  </code></pre>
  
  <p>and i create a batch to go to the path...</p>
  
  <pre><code>for /F "skip=1 tokens=*" %%a in ('wmic csproduct get name') do if not defined model set model=%%a
  
  cd windows\%model%\test
  </code></pre>
  
  <p>................................</p>
  
  <p>this bombs out because the %model% is returning  <code>"c:\windows\637263G \test"</code> and not <code>"c:\windows\637263G\test"</code></p>
  
  <p>It's leaving a space after the model name.</p>
  
  <p>Does anyone know how to remove the space at the back?</p>