title: Copy specific amount of files to changing directory with Batch script?
body: <p>So I am trying to create a batch script that takes photos from an SD card and places it in a sub-directory. I then need to take a specific amount of photos (eight) and place them in a separate sub-directory, then take the next eight photos and place them in a subsequent sub-directory. In other words, say I have 32 photographs. My script needs to copy them to say C:\Photos. I then need the script to take the first eight photos and copy/paste them into C:\Photos\1. Then I need the next eight photos to be copied/pasted into C:\Photos\2 and so on.</p>
  
  <p>I already know how to copy the files from one directory to another (kind of). All of the sub-directory folders are created earlier within my script. So I have this section of code:</p>
  
  <pre><code>set cnt=0
  set folder=1
  
  for %%P in ("C:\Photos\") do (
      set /a cnt+=1
      if exist %%P\*.jpg COPY %%P\*.jpg C:\Photos\%folder%
      echo count = %cnt%
  )
  </code></pre>
  
  <p>The goal of this code (well, what I want it to do) is, for each file in the C:\Photos directory, add one (1) to the cnt variable, and display the value of that cnt variable. The problem is, the way the code sits, it copies the files properly, but does not count. It only counts one (1) file. However, if I add *.jpg to the first part like this</p>
  
  <pre><code>for %%P in ("C:\Photos\*.jpg") do (
  </code></pre>
  
  <p>It counts the proper amount of files, but the copying doesn't work. What gives? </p>
  
  <p>Also, since for debugging purposes, I want it to echo the current count after each file is counted/copied. The way I have it, the count seems to change, but won't display. </p>
  
  <p>Edit: New problem. I have my test images labeled as img1, 2, 3 and so on. When I run the code, it seems to go through them in a random order. If I run through 32 files the order is as follows: Img 1, 3, 13, 8, 7, 6, 5, 4, 2, 11,  12, 14, 15, 16, 18, 19, 22, 9, 10, 21, 23, 24, 31, 32, 17, 25, 26, 27, 28, 29 and 30. Seems pretty random to me and the order is the same every time the script is ran. </p>