blob: 0a63586f580b112b592fc946de3d27561d81ce0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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}"/*
|