get first characters of expansion parameter of find command I have a huge collection of images and I would like to put them in folders matching their first 3 charachers+.jpg extension.

So i would like to grab 4_1_0002.png file (all the files starting with 4_1) and put it in the 4_1_.jpg folder. Similarly I would like to grab 4_2_0002.png file (all the files starting with 4_2) and put it in the 4_2_.jpg folder.

All those files that I would like to sort are now in one huge folder.
I expected to use a find command, but I don't know how to extract the first three characters from {} expansion parameter.

find . -type f -ok echo mv {} "path/first3char.jpg" \;
Assuming that all your files are in the same directory and the filenames are reasonable sane, something like

 find . -maxdepth 1 -type f -name '*png' |
     while read line; do
         echo mv "$line" "path/${line:2:3}.jpg/"
     done


Run the command first as written (including the echo) to check whether the result makes sense. Then remove the echo and rerun.