cleanup scanbuddy script

This commit is contained in:
Prunebutt 2025-09-27 15:51:35 +02:00
parent 8542ea2ef7
commit b421e330f4

View file

@ -13,7 +13,6 @@ sides=$simplex_source
mode='c'
resolution='300'
current_page=$(find "$PWD" -name "out*.pdf" | sort | tail -n 1);
read -r current_pageno <<<"${current_page//[^0-9]/ }"
current_pageno=${current_pageno:-0}
@ -77,19 +76,12 @@ scan() {
-x 210 -y 297 # A4
}
if [ "$#" -lt 1 ]; then
echo "You need an argument!"
exit 1
fi
clean() {
echo "Cleaning up..."
rm -rfv "$PWD/out*.pdf"
}
case "$1" in
scan)
scan "${@:2}"
;;
unscan)
rm "$last_out_file"
;;
dispatch)
dispatch() {
readarray -d '' out_files < <(find . -regextype posix-awk -regex "\./out[0-9]+\.pdf" -print0 | sort -Vz)
combined_file=$(mktemp --suff="_scanbuddy.pdf")
gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE="$combined_file" -dBATCH "${out_files[@]}"
@ -107,8 +99,29 @@ case "$1" in
else
printf "Paperless consumption job: %s\n" "$PAPERLESS_STATUS"
fi
clean
}
if [ "$#" -lt 1 ]; then
echo "You need an argument!"
exit 1
fi
case "$1" in
scan)
scan "${@:2}"
;;
unscan)
rm "$last_out_file"
;;
dispatch)
dispatch "${@:2}"
;;
clean)
clean
;;
*)
echo "Usage: scanbuddy"
echo "Usage: scanbuddy scan|unscan|dispatch|clean"
;;
esac