#!/bin/bash# help# $1 pdf file name. A image exported from acrobat, is prefixed by the pdf file name# $2 conut of images to concatCOUNTER=1
CONCAT_NUM=$2IN_FILES=" "OUT_COUNT=1
for f in$(ls -1 "$1"*.jpg | sort)do
IN_FILES=$IN_FILES"$f "MOD=$(($COUNTER%$CONCAT_NUM))echo"MOD: $MOD"echo"IN_FILES: $IN_FILES"if[$MOD= 0 ]; then
echo"MOD == 0"
convert $IN_FILES -append $1"-concat-"$OUT_COUNT".jpg"let OUT_COUNT=$OUT_COUNT+1
IN_FILES=" "fi
let COUNTER=$COUNTER+1
done
if[$MOD != 0 ]; then
convert $IN_FILES -append $1"-concat-"$OUT_COUNT".jpg"fi
echo"MOD: $MOD"echo"COUNTER: $COUNTER"