-
-
Save sysnajar/c43918ad3b8adb78ec7027c8441f3c56 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