Split contents of a directory into multiple sub directories

the following worked well for me. Open the directory in terminal, and just copy & paste the following script, press enter. sub directories will be created inside having names dir_001, dir_002 and so on.

i=0; 
for f in *; 
do 
    d=dir_$(printf %03d $((i/100+1))); 
    mkdir -p $d; 
    mv "$f" $d; 
    let i++; 
done

Move fixed number of files using array with range and offset.

#!/bin/bash

shopt -s nullglob

a=(./src/*)
for ((i=0; i<${#a[@]}; i+=100)); do
    printf -v b ./img_%03d $((++n))
    mkdir -p $b && mv -t $b "${a[@]:$i:100}"
done