Skip to content

Instantly share code, notes, and snippets.

@smowtion
Created October 4, 2018 02:34
Show Gist options
  • Select an option

  • Save smowtion/eb058461b00d8896cd61cde7d6c3ef7e to your computer and use it in GitHub Desktop.

Select an option

Save smowtion/eb058461b00d8896cd61cde7d6c3ef7e to your computer and use it in GitHub Desktop.
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
pdftk_path="/usr/local/bin/pdftk" # full path to pdftk binary
pdf_infokeys="~/pdf-infokeys" # full path to file containing new metadata
pdf_search_path="/var/www/html" # path to search for pdf files
pdf_temp_path="/tmp" # temporary directory
for i in $( find $pdf_search_path -type f -name "*.pdf" ); do
cp $i $pdf_temp_path/temp.pdf
$pdftk_path $pdf_temp_path/temp.pdf update_info $pdf_infokeys output $i
rm $pdf_temp_path/temp.pdf
done
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment