From: martin f. krafft Date: Thu, 30 Oct 2014 11:31:10 +0000 (+0100) Subject: remove pages from original file in pdfextract X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/8381ec42c81bc4e252e4310dc78a4fea5880fddb?hp=ba79da8b82d0d955a1ae93b8d38eaa49468ca346 remove pages from original file in pdfextract --- diff --git a/.zsh/zshrc/30_aliases b/.zsh/zshrc/30_aliases index 7acf460..d806681 100644 --- a/.zsh/zshrc/30_aliases +++ b/.zsh/zshrc/30_aliases @@ -211,6 +211,15 @@ pdfextract() { local o=$2 shift 2 pdftk "$i" cat "${@:-1-end}" output "${o%.pdf}.pdf" + if [ -n "$1" ]; then + local tmpfile + tmpfile=$(tempfile -p pdftk -s .pdf) + cleanup() { rm -f $tmpfile; trap - EXIT; } + trap cleanup EXIT + pdftk "$i" cat "1-end~${(j:~:)@}" output $tmpfile + mv $tmpfile "$i" + cleanup + fi } compdef _files pdfextract