title: How does "FOR" work in cmd batch file?
body: <p>I've been programming in dozens of languages for 20 years but I could never understand how "FOR" work in windows cmd shell batch file, no matter how hard I tried.  I read </p>
  
  <p><a href="https://rads.stackoverflow.com/amzn/click/com/0470046163" rel="noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Windows-Administration-Command-Line-Vista/dp/0470046163/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1241362727&amp;sr=8-1</a></p>
  
  <p><a href="http://www.ss64.com/nt/for.html" rel="noreferrer">http://www.ss64.com/nt/for.html</a></p>
  
  <p>and several other articles on the internet but still confuse and cannot accomplish anything.</p>
  
  <p>Can anybody give me a concise explaination on how "FOR" works in general ?</p>
  
  <p>For a little more specific question, how can I iterate through each path in %PATH% variable ?
  I've tried with </p>
  
  <pre><code>rem showpathenv.bat
  for /f "delims=;" %%g in ("%PATH%") do echo %%g
  </code></pre>
  
  <p>That'd show only the first path, not all of them. Why ? What I do wrong ?</p>