I’ve just written a little wrapper around pdftk to simplify the modification of PDF file meta-data.
It extracts the existing meta-data, opens it in your favourite editor, writes it back to the original PDF and finally removes the temporary files it generated.
#! /bin/sh if [ ! -f "$1" ] then echo "Usage: $0" exit 1 fi FILE=$(tempfile --prefix=pdf-metadata-) pdftk "$1" dump_data output $FILE creation_time=$(stat -c %Y $FILE) $EDITOR $FILE if [ "$(stat -c %Y $FILE)" -le $creation_time ] then echo "Information not modified, aborting." rm -f "$FILE" exit 2 fi output_file=$(tempfile --prefix=pdf-modified-) pdftk "$1" update_info $FILE output "$output_file" || \ (rm -f $FILE && exit 3) mv -f "$output_file" "$1" rm -f $FILE
I thought I’d share it in case anyone else finds it useful. Do whatever you want with it; if you want to use it somewhere serious, the ISC License is fine.
Thank You, it is a great script. One suggestion: You may recoll, that $EDITOR must be set in .bashrc at first.
Useful. Thanks.