Instead of selecting the graphics acccording to a fixed value (e.g. at step 65 select file 65), we use a method that works with any given number of files:
List all pdf-files in the
ls $TMP/*.pdf, take the amount according to the current grid type with
head -n $GRIDTYPE,
take the amount according to the current step with
head -n $GRAFIKCOUNT, select the last one
while [ $GRAFIKCOUNT -le $MAXGRAFIKS ] do GRAFIK=`ls $TMP/*.pdf | head -n $GRIDTYPE | \ head -n $GRAFIKCOUNT | \ tail -1` GRAFIKCOUNT=`expr $GRAFIKCOUNT + 1` done
This way we get a file, wether there are 1 or 500 in the folder. If the generator script did not produce enough files, for any reason, there is no need to have an exception. This soft selecting method will compensate the error through. Errors will not cause stoppin but the change the visual output.