I'm trying to group files arranged in some order so that I can zip them. I have m*n files in my folder and wish to move n files to m folders such that they're arranged in alphabetical order (or date created order, whichever is doable). So for files {A,B,C,D,E,F} I wish to create two new folders 1 and 2 such that 1 contains {A,B,C} and 2 contains {D,E,F}. If there's code to do the same thing on a mac, that would be great too, but I'm primarily looking to do this on windows.
I found a similar question, however I'm not able to create new folders within the loop or move the files to them.
@echo off
set /a "filesPerChunk=3, idx=0"
set /a fcount=1
for /F "delims=" %%I in ('dir /a-d /b') do (
echo Processing %%I
set /a "idx=idx+1"
set /a "mod=idx %% filesPerChunk"
if !mod! equ 0 (
md File-%fcount%
echo --- END OF CHUNK %fcount% ---
pause
)
move I File-%fcount%
if !mod! equ %filesPerChunk%-1(
set /a fcount+=1
)
)
I was trying to extract values from fcount to make new folders, but as I mentioned, I don't have a lot of experience writing batch scripts so I don't know if this even makes sense.
EDIT: So I had to move a few commands here and there because I realized I wouldn't be able to move the files if I had just the final check when creating the file, but I'm not sure if it works