From 8381ec42c81bc4e252e4310dc78a4fea5880fddb Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Thu, 30 Oct 2014 12:31:10 +0100 Subject: [PATCH 1/1] remove pages from original file in pdfextract --- .zsh/zshrc/30_aliases | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.39.5