Created
February 28, 2011 02:25
-
-
Save jeremyBanks/846847 to your computer and use it in GitHub Desktop.
A script for quickly editing PDF metadata with pdftk and TextMate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
subject="$1" | |
name="$(basename "$subject")" | |
path="$(dirname "$subject")" | |
tmp_new="$path/__tmp_new_$name" | |
tmp_meta="$path/__tmp_meta_$name.txt" | |
echo "Dumping metadata..." && | |
pdftk "$subject" dump_data > "$tmp_meta" && | |
echo "Opening metadata..." && | |
mate -w "$tmp_meta" && | |
echo "Writing new PDF..." && | |
pdftk "$subject" update_info "$tmp_meta" output "$tmp_new" && | |
echo "Removing metadata file..." && | |
rm -f "$tmp_meta" && | |
echo "Trashing original PDF..." && | |
mv -f "$subject" "$HOME/.Trash/($(date)) $name" && | |
echo "Placing new PDF..." && | |
mv "$tmp_new" "$subject" && | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment