I think that alphabetic sorting is also inside for loop, so it should be changed there also
=============== edit 2 ========================
printf '%s\n' *.gif | sort -n
-1.000000.gif
0.000000.gif
-0.200000.gif
0.200000.gif
-0.400000.gif
0.400000.gif
-0.600000.gif
0.600000.gif
-0.800000.gif
0.800000.gif
a200.gif
1.000000.gif
locale
LANG=pl_PL.UTF-8
LANGUAGE=
LC_CTYPE="pl_PL.UTF-8"
LC_NUMERIC="pl_PL.UTF-8"
LC_TIME="pl_PL.UTF-8"
LC_COLLATE="pl_PL.UTF-8"
LC_MONETARY="pl_PL.UTF-8"
LC_MESSAGES="pl_PL.UTF-8"
LC_PAPER="pl_PL.UTF-8"
LC_NAME="pl_PL.UTF-8"
LC_ADDRESS="pl_PL.UTF-8"
LC_TELEPHONE="pl_PL.UTF-8"
LC_MEASUREMENT="pl_PL.UTF-8"
LC_IDENTIFICATION="pl_PL.UTF-8"
LC_ALL=
CodePudding user response:
This appears to be a matter of sorting. You currently use *.gif
, which is expanded into an alphabetically sorted list of files. But you need a numerically sorted list of files here instead to achieve your goal. Additionally, your locale settings affect sorting (see man sort
).
Try this:
readarray -t files < <(printf '%s\n' *.gif | LC_ALL=C sort -n)
convert "${files[@]}" -resize 600x600 a600_100.gif
or this:
readarray -t files < <(find . -maxdepth 1 -type f -name '*.gif' -printf "%f\n" | LC_ALL=C sort -n)
convert "${files[@]}" -resize 600x600 a600_100.gif
instead of:
convert *.gif -resize 600x600 a600_100.gif