This script doesn't not work well with file names with tab character. Changing read name size to read size name and -printf "%f\t%s\n" to -printf "%s\t%f\n"should fix it.
–
mattMay 25 at 15:36

Note also that this script doesn't work well with files without extension. It will treat whole file name as extension. Add if [ "$name" == "$ext" ]; then ext="*no_extension*"; fi after ext=${name##*.} if you need to prevent it. This will put all files without extension into *no_extension* group (I'm using *no_extension* because * is not a valid character in file name)
–
mattMay 25 at 15:39