I would like to build an Automator application that counts the files in the hostfolder, creates a numbered subfolder named " [hostFolder name] [counter] ", moves at maximum 128 files from hostFolder in sequential order into this new subfolder, and loops until all files in hostFolder are sorted into subfolders (i.e. the last subfolder will have fewer than 128 files in it). Before the workflow runs, the hostfolder will always only contain files, no subfolders.
Here's the desired outcome of my ideal workflow using as an example an arbitrary folder containing an arbitrary number of files, also arbitrarily named. (Note I do not need the workflow to rename any files):
A folder named Beans contains 1027 files, the files Legume 0001 to Legume 1027. My Automator application receives the folder Beans as input. Once the workflow has run, the folder Beans now contains 9 subfolders, named Beans 1, Beans 2, Beans 3, and so on all the way to Beans 9.
The subfolder Beans 1 contains files Legume 0001, Legume 0002, Legume 0003, and so on to Legume 0128. The subfolder Beans 2 contains the files Legume 0129 to Legume 0256. In other words, each subfolder contains 128 of the files named Legume **** in sequential order. The only exception is the final subfolder, Beans 9, which contains only 3 files, the files Legume 1025, Legume 1026, and Legume 1027.