Fix minor typo, add thingy_compress.sh to allow compressing of existing downloads
authorOliver Matthews <oliver@codersoffortune.net>
Thu, 16 Jul 2020 10:30:34 +0000 (11:30 +0100)
committerOliver Matthews <oliver@codersoffortune.net>
Thu, 16 Jul 2020 10:30:34 +0000 (11:30 +0100)
thingy_compress.sh [new file with mode: 0755]

diff --git a/thingy_compress.sh b/thingy_compress.sh
new file mode 100755 (executable)
index 0000000..d4d641c
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+sourcefile=${1%/}
+
+if [ ! -d "$sourcefile" ]
+then
+    echo "$1 does not appear to be a directory."
+    exit 1
+fi
+
+timestamp=$(cat "$sourcefile/timestamp.txt")
+
+if [ -z "$timestamp" ]
+then
+    echo "No timestamp?"
+    exit 1
+fi
+
+output="${sourcefile} - ${timestamp}.7z"
+
+if [ -f "${output}" ]
+then
+    echo "Target file ${output} already exists"
+    exit 1
+fi
+
+7z a -mx=9 "${output}" "${sourcefile}"