mirror of
https://github.com/rocketraman/sane-scan-pdf.git
synced 2025-05-29 13:40:09 -07:00
Remove use of stack.sh, use bash arrays
This commit is contained in:
parent
51d2afcd54
commit
0b42ed821d
15
scan
15
scan
@ -189,14 +189,13 @@ echo >&2 "Scanning..."
|
|||||||
eval scanadf -d $DEVICE $MAXPAGE $PGHEIGHT $PGWIDTH -S $SCRIPT --script-wait --resolution $RESOLUTION --mode $MODE $DESKEW $CROP $SOURCE -o scan-%04d
|
eval scanadf -d $DEVICE $MAXPAGE $PGHEIGHT $PGWIDTH -S $SCRIPT --script-wait --resolution $RESOLUTION --mode $MODE $DESKEW $CROP $SOURCE -o scan-%04d
|
||||||
|
|
||||||
shopt -s extglob nullglob
|
shopt -s extglob nullglob
|
||||||
numscans=$(ls scan-[0-9]*.pdf | wc -w)
|
pdffiles=(scan-[0-9]*.pdf)
|
||||||
|
numscans=${#pdffiles[@]}
|
||||||
if [ $numscans -gt 0 ]; then
|
if [ $numscans -gt 0 ]; then
|
||||||
echo ""
|
|
||||||
echo "Processing $numscans pages"
|
echo "Processing $numscans pages"
|
||||||
if [ $TRUNCPAGE -gt 0 ]; then
|
if [ $numscans -gt $TRUNCPAGE -a $TRUNCPAGE -gt 0 ]; then
|
||||||
source /usr/local/bin/stack.sh
|
for x in ${pdffiles[@]:$numscans-$TRUNCPAGE:$TRUNCPAGE}; do rm "$x"; done;
|
||||||
for x in scan-[0-9]*; do push $x; done;
|
pdffiles=(${pdffiles[@]:0:$numscans-$TRUNCPAGE})
|
||||||
for x in $(seq $TRUNCPAGE); do rm $(pop); done;
|
|
||||||
echo "Truncated $TRUNCPAGE pages"
|
echo "Truncated $TRUNCPAGE pages"
|
||||||
fi
|
fi
|
||||||
if [ $numscans -gt 1 -a $USEARRAY = 1 ]; then
|
if [ $numscans -gt 1 -a $USEARRAY = 1 ]; then
|
||||||
@ -205,7 +204,6 @@ if [ $numscans -gt 0 ]; then
|
|||||||
index=0
|
index=0
|
||||||
while [ "$index" -lt "$output_count" ]; do
|
while [ "$index" -lt "$output_count" ]; do
|
||||||
let "scanno = $index + 1"
|
let "scanno = $index + 1"
|
||||||
echo "scanno = $scanno"
|
|
||||||
if [ -f "${OUTPUT[$index]}" ]; then
|
if [ -f "${OUTPUT[$index]}" ]; then
|
||||||
mv "${OUTPUT[$index]}" "${OUTPUT[$index]}.orig"
|
mv "${OUTPUT[$index]}" "${OUTPUT[$index]}.orig"
|
||||||
if [ $APPEND -eq 1 ]; then
|
if [ $APPEND -eq 1 ]; then
|
||||||
@ -213,8 +211,6 @@ if [ $numscans -gt 0 ]; then
|
|||||||
if [ -f "${OUTPUT[$index]}.orig" ]; then
|
if [ -f "${OUTPUT[$index]}.orig" ]; then
|
||||||
pdffiles+=("${OUTPUT[$index]}.orig")
|
pdffiles+=("${OUTPUT[$index]}.orig")
|
||||||
fi
|
fi
|
||||||
echo "index = $index"
|
|
||||||
echo "scanno = $scanno"
|
|
||||||
pdffiles+=(scan-*(0)$scanno.pdf)
|
pdffiles+=(scan-*(0)$scanno.pdf)
|
||||||
pdfunite "${pdffiles[@]}" "${OUTPUT[$index]}" && rm scan-*(0)$scanno.pdf
|
pdfunite "${pdffiles[@]}" "${OUTPUT[$index]}" && rm scan-*(0)$scanno.pdf
|
||||||
else
|
else
|
||||||
@ -234,7 +230,6 @@ if [ $numscans -gt 0 ]; then
|
|||||||
if [ -f "${OUTPUT}.orig" ]; then
|
if [ -f "${OUTPUT}.orig" ]; then
|
||||||
pdffiles+=("${OUTPUT}.orig")
|
pdffiles+=("${OUTPUT}.orig")
|
||||||
fi
|
fi
|
||||||
shopt -s nullglob
|
|
||||||
pdffiles+=(scan-[0-9]*.pdf)
|
pdffiles+=(scan-[0-9]*.pdf)
|
||||||
pdfunite "${pdffiles[@]}" "$OUTPUT" && rm scan-[0-9]*.pdf
|
pdfunite "${pdffiles[@]}" "$OUTPUT" && rm scan-[0-9]*.pdf
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user