title: Batch file to count files matching first 6 characters in file name and output file group and its count
body: <p>I would like to have a batch file to count all file names with common prefix and output the file group and its count. I have these files in a directory:</p>
  
  <ul>
  <li>A1110601.zip</li>
  <li>A1110602.zip</li>
  <li>A1110603.zip</li>
  <li>A1120601.zip</li>
  <li>A1120602.zip</li>
  </ul>
  
  <p>I want to group the first 3 by <code>A11106*.zip</code> and the last two by <code>A11206*.zip</code>.</p>
  
  <p>My desired output is:</p>
  
  <pre><code>A11106: 3
  A11206: 2
  </code></pre>
  
  <p>I have tried to copy sample codes from the forum, but they don't fulfilled my desired output.</p>
  
  <p>Here is the code I have so far. But the output is not as described above.</p>
  
  <pre><code>@echo off
  title Store Data Counter
  :recurse
  set I=1
  echo "files counter"
  
  FOR /f "tokens=*" %%A IN ('dir /a-d /b "Z:\StoreData\A11106*.zip"') do (call :showfiles "%%A")
  echo A111: %I%
  
  FOR /f "tokens=1" %%A IN ('dir /a-d /b "Z:\StoreData\A11206*.zip"') do (call :showfiles "%%A")
  echo A112: %I%
  
  pause
  goto :eof
  
  :showfiles
  echo %1
  set /a I+=1
  goto :eof
  </code></pre>