#!/bin/bash # check parameter if [ $# -lt 1 ]; then echo "USAGE: $0 LIST_NO" exit else LISTID=$1 fi function create_pdfmark() { cat <<EOF> /tmp/pdfmarks [ /Author (panticz.de) /Creator (panticz.de) /Producer (panticz.de) /Keywords ($1, panticz.de) /Title (panticz.de ${LISTID} - $1) /Subject (panticz.de ${LISTID}) /DOCINFO pdfmark EOF } for DIR in * do if [ -d "${DIR}" ]; then # convert to lowercase OUT=$(echo ${DIR} | tr "[:upper:]" "[:lower:]") # filter OUT="${OUT// /_}" # replace " " with "_" OUT="${OUT//ä/ae}" # replace "ä" with "ae" OUT="${OUT//ö/oe}" # replace "ö" with "oe" OUT="${OUT//ü/ue}" # replace "ü" with "ue" OUT="${OUT//,/}" # remove "," # create pdfmarks file TITLE=${DIR#* } create_pdfmark "${TITLE}" # create pdf cd "./${DIR}/" gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile=../l${LISTID}_${OUT}.pdf *.pdf /tmp/pdfmarks cd .. fi done