Fix the multi-output loop

Resolves #33.

Fixes the arithmetic comparison in the while loop being
incorrect.

Also, handles the situation in which there are more output
files being specified than scans available, in addition
to the already handled reverse situation.
This commit is contained in:
Raman Gupta 2021-08-06 12:49:03 -04:00
parent f9d329cf27
commit d716cdbe8c

4
scan
View File

@ -283,10 +283,10 @@ if [[ $numscans > 0 ]]; then
echo "Truncated $TRUNCPAGE pages" echo "Truncated $TRUNCPAGE pages"
fi fi
if [[ $numscans > 1 && $USEARRAY == 1 ]]; then if [[ $numscans > 1 && $USEARRAY == 1 ]]; then
echo "Naming pdfs based on output list..."
output_count=${#OUTPUT[@]} output_count=${#OUTPUT[@]}
echo "Naming $numscans pdfs based on output list of $output_count names..."
index=0 index=0
while [[ "$index" < "$output_count" ]]; do while (( $index < $output_count && $numscans > $index )); do
let "scanno = $index + 1" let "scanno = $index + 1"
if [[ -f "${OUTPUT[$index]}" ]]; then if [[ -f "${OUTPUT[$index]}" ]]; then
mv "${OUTPUT[$index]}" "${OUTPUT[$index]}.orig" mv "${OUTPUT[$index]}" "${OUTPUT[$index]}.orig"