From 09c655e2c12c51d8f19401df838bb373e520e6cc Mon Sep 17 00:00:00 2001 From: Niklas Halle Date: Sun, 26 Jul 2020 13:46:38 +0200 Subject: Added wrapper script for the full pipeline --- paperless_pipeline | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 paperless_pipeline diff --git a/paperless_pipeline b/paperless_pipeline new file mode 100755 index 0000000..52b67d1 --- /dev/null +++ b/paperless_pipeline @@ -0,0 +1,53 @@ +#!/bin/env bash + +filename="${1}" +full_filename="${filename}.pdf" +title="${2}" +correspondent="${3}" +tags="${4}" + +if [ -z "${filename}" ] || [ -z "${title}" ] || [ -z "${correspondent}" ]; then + echo "Usage: ${0} filename title correspondent [tags(csv)]" + exit 1 +fi + +echo +echo " #######################" +echo " # preparing paperless #" +echo " #######################" + +if ! prepare_paperless "${filename}"; then + echo "Could not prepare pdf for paperless (scan, shrink)" + exit 2 +fi + +echo +echo " #######################" +echo " # uploading file #" +echo " #######################" +if [ -n "${tags}" ]; then + command="paperless_upload --title \"${title}\" --correspondent \"${correspondent}\" --tags ${tags} ${full_filename}" +else + command="paperless_upload --title \"${title}\" --correspondent \"${correspondent}\" ${full_filename}" +fi + +echo "command: ${command}" +command="$(eval "${command}")" + +echo +echo " #######################" +echo "${command}" +echo " #######################" + +if echo "${command}" | bash; then + rm "${full_filename}" + echo + echo " #######################" + echo " # done #" + echo " #######################" +else + echo + echo " #######################" + echo " # error #" + echo " #######################" +fi \ No newline at end of file -- cgit v1.2.3-54-g00ecf