title: Batch files - number of command line arguments
body: <p>Just converting some shell scripts into batch files and there is one thing I can't seem to find...and that is a simple count of the number of command line arguments.</p>
  
  <p>eg. if you have:</p>
  
  <pre><code>myapp foo bar
  </code></pre>
  
  <p>In Shell:</p>
  
  <ul>
  <li>$# -> 2</li>
  <li>$* -> foo bar</li>
  <li>$0 -> myapp</li>
  <li>$1 -> foo</li>
  <li>$2 -> bar</li>
  </ul>
  
  <p>In batch</p>
  
  <ul>
  <li><strong>?? -> 2   &lt;---- what command?!</strong></li>
  <li>%* -> foo bar</li>
  <li>%0 -> myapp</li>
  <li>%1 -> foo</li>
  <li>%2 -> bar</li>
  </ul>
  
  <p>So I've looked around, and either I'm looking in the wrong spot or I'm blind, but I can't seem to find a way to get a count of number of command line arguments passed in.</p>
  
  <p>Is there a command similar to shell's "$#" for batch files?</p>
  
  <p>ps. the closest i've found is to iterate through the %1s and use 'shift', but I need to refernece %1,%2 etc later in the script so that's no good.</p>