First made for make art 2009 posters.

Instead of select­ing the graph­ics acc­cord­ing to a fixed value (e.g. at step 65 select file 65), we use a method that works with any given num­ber of files:

List all pdf-files in the tmp directory with ls $TMP/*.pdf, take the amount accord­ing to the cur­rent grid type with head -n $GRIDTYPE, take the amount accord­ing to the cur­rent step with head -n $GRAFIKCOUNT, select the last one with tail -1.

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 gen­er­a­tor script did not pro­duce enough files, for any rea­son, there is no need to have an excep­tion. This soft select­ing method will com­pen­sate the error through. Errors will not cause stop­pin but the change the visual output.