From 76360d09fa267c605f90dd7658961c984e27a74a Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sat, 18 Feb 2017 16:47:30 +0100 Subject: [PATCH] Change PDF metadata --- scripts/install-prefs | 2 +- scripts/pdfrename | 49 +++++++++++++++++++++++++++++++++++++++++++ vimrc | 2 +- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100755 scripts/pdfrename diff --git a/scripts/install-prefs b/scripts/install-prefs index 6dfe8b2..191a76c 100755 --- a/scripts/install-prefs +++ b/scripts/install-prefs @@ -280,7 +280,7 @@ if [ $EXTRA == 1 ]; then inst sl ffmpeg youtube-dl if [ $ARCH == 1 ]; then - altInst pdftk + altInst pdftk translate-shell fi # Extra GUI diff --git a/scripts/pdfrename b/scripts/pdfrename new file mode 100755 index 0000000..7cfdd9c --- /dev/null +++ b/scripts/pdfrename @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Change the title of a PDF file + +if [[ -z "$1" || -z "$2" ]]; then + echo "Usage: $0 FILE TITLE [CREATOR [PRODUCER]]" + echo + echo "Arguments:" + echo " FILE Path to the PDF document" + echo " TITLE Content of the Title tag" + echo " CREATOR Content of the Creator tag" + echo " PRODUCER Title to give" + exit 1 +fi + +file="$1" +title="$2" +creator="$3" +producer="$4" + +if [ ! -f "$1" ]; then + echo "No such file or directory: $1" >> /dev/stderr + exit 2 +fi + +instructions=$(mktemp) + +echo "InfoBegin" >> "$instructions" +echo "InfoKey: Title" >> "$instructions" +echo "InfoValue: $title" >> "$instructions" +if [ -n "$creator" ]; then + echo "InfoBegin" >> "$instructions" + echo "InfoKey: Creator" >> "$instructions" + echo "InfoValue: $creator" >> "$instructions" +fi +if [ -n "$producer" ]; then + echo "InfoBegin" >> "$instructions" + echo "InfoKey: Producer" >> "$instructions" + echo "InfoValue: $producer" >> "$instructions" +fi + +copy=$(mktemp) +cp "$file" "$copy" + +pdftk "$copy" update_info "$instructions" output "$file" + +rm "$instructions" "$copy" + + diff --git a/vimrc b/vimrc index e5df06c..c2d7a89 100644 --- a/vimrc +++ b/vimrc @@ -22,7 +22,7 @@ Plugin 'tpope/vim-repeat' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' Plugin 'airblade/vim-gitgutter' -Plugin 'kien/ctrlp.vim' +Plugin 'ctrlpvim/ctrlp.vim' Plugin 'mbbill/undotree' Plugin 'xolox/vim-misc' Plugin 'xolox/vim-easytags'