summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpaperless_pipeline53
1 files changed, 53 insertions, 0 deletions
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