awk one-liner can do this. Consider this awk command:
find . -name "*.JPG" | awk '!(++cnt%100) {"mkdir sub_" ++d|getline}'
Run it in the folder with 5000 images. This will create 50 folders named sub_1, sub_2 ... sub_50.
Also move files to these newly created directories:
find . -type f | awk '{ a[++cnt] = $0 } cnt==100 { subd = "sub_" ++d; system("mkdir " subd); for (f in a) system("mv " a[f] " " subd); cnt=0 }'
anubhava
source share