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" ]
	echo "Usage: $0"
	exit 1

FILE=$(tempfile --prefix=pdf-metadata-)
pdftk "$1" dump_data output $FILE
creation_time=$(stat -c %Y $FILE)

if [ "$(stat -c %Y $FILE)" -le $creation_time ]
	echo "Information not modified, aborting."
	rm -f "$FILE"
	exit 2

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.