You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
703 B
Bash

#!/bin/sh
# Script converts first page of PDFs to a jpeg with the ending _cover.jpeg
# Software dependencies: gs
# Usage: ./pdf_cover.sh imgs-dir-name
DIR=""
echo ${#1}
if [ ${#1} -gt 0 ] # check arguments given
then
DIR=$1
echo "PDF from $DIR directory: cover converted to png"
for f in $DIR/*.pdf # convert imgs to tmp pdfs
do
COVER=$DIR/`basename "$f" .pdf`_cover.jpeg
echo $COVER
gs -q -dNOPAUSE -dSAFER -dBATCH -sDEVICE=jpeg -r300x300 -sOutputFile="$COVER" -dLastPage=1 "$f"
# convert "$f"[0] "$COVER"
done
# pdftk $DIR*.pdf cat output $FILENAME # concatonate single pdf into 1 pdf
else
echo "You forgot to provide the PDFs directory as first argument"
fi