Skip to content

Instantly share code, notes, and snippets.

Last active October 6, 2021 03:22
What would you like to do?
Extract and Combine First Page of each PDF in folder - OS X, requires GS or PDFTK
echo "Start Script"
rm combined.pdf
for file in *.pdf ; do pdftk "$file" cat 1 output "${file%.pdf}-page1.pdf" ; done
pdftk *-page1.pdf cat output combined.pdf
#for file in *.pdf ; do gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="${file%.pdf}-page1.pdf" -dFirstPage=1 -dLastPage=1 "$file" ; done
#gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -sOutputFile#"combined.pdf" *-page1.pdf
rm *-page1.pdf
echo "End Script"
Copy link

eplt commented Sep 7, 2016

You might need to install Ghostscript or PDFTK

Check out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment