Question: I have a directory which contain more than thousand images. I want to split the files in to multiple sub directories, each containing 100 files. How do I do this?

Answer: 
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.

```bsh
#!/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

```