Searches for all PDF files in the current directory and deletes all leaving just the first page.
#!/bin/bash
###############################################################################
## Searches for all PDF files in the current directory and deletes all pages
## leaving just the first page.
##
## Useful for forms that include duplicated pages, where you only need the first page
##
## Depends on the pdftk command line tool. Install in Linux by using,
##
## sudo apt-get install pdftk
##
###############################################################################
mkdir output
for file in *; do
if [[ -f $file ]]; then
if [[ $file == *".pdf" ]]; then
pdftk A="$file" cat A1-1 output ./output/"$file"
fi
fi
done