aboutsummaryrefslogtreecommitdiff
path: root/pdfs/pdfSxiv.sh
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2019-12-02 14:23:33 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2019-12-02 14:23:33 +0100
commit58a9e65b5554b2c9552540dfea96b562375cf321 (patch)
tree118dbc0f74d7d09c328e5fbdecd118c7f3f23ee4 /pdfs/pdfSxiv.sh
parent1ab2d661fb0ffa625d828792deabfb92a5c3611a (diff)
downloadscripts-58a9e65b5554b2c9552540dfea96b562375cf321.tar.gz
scripts-58a9e65b5554b2c9552540dfea96b562375cf321.zip
Mon 02 Dec 2019 02:23:33 PM CET
Diffstat (limited to 'pdfs/pdfSxiv.sh')
-rwxr-xr-xpdfs/pdfSxiv.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/pdfs/pdfSxiv.sh b/pdfs/pdfSxiv.sh
new file mode 100755
index 0000000..0a63586
--- /dev/null
+++ b/pdfs/pdfSxiv.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# pdfSxiv.sh
+#
+# Usage: pdfSxiv.sh FILE
+#
+# Opens all images of a pdf with sxiv
+
+[ -z "$1" ] && exit 1
+
+baseDir="/tmp/pdfSxiv"
+directory="${1##*/}"
+directory="${directory%%.*}"
+fullPath="${baseDir}/001-${directory}"
+if [ -d "$fullPath" ]; then
+ last="$(ls "${fullPath}/.." | sort | tail -n 1)"
+ last="${last%%-*}"
+ while echo "$last" | grep -E -q '^0'; do
+ last="${last#0}"
+ done
+ index="$((last+1))"
+ while ! echo "$index" | grep -E -q '.{3}'; do
+ index="0$index"
+ done
+ fullPath="${baseDir}/${index}-${directory}"
+fi
+
+mkdir -p "$fullPath"
+pdfimages -png "$1" "${fullPath}/pdfSxiv"
+sxiv "${fullPath}"/*