aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-01-18 14:09:04 -0200
committerSilvio Rhatto <rhatto@riseup.net>2019-01-18 14:09:04 -0200
commit23ea5f38f2232e77d22b57be096b1281df90d29f (patch)
treef776e54e015fe73591dc050ac285332c922a9ec7
parent310d2a7e5a7fb9a7b6e88cb9e40f80ccc82c7a7a (diff)
downloadscripts-23ea5f38f2232e77d22b57be096b1281df90d29f.tar.gz
scripts-23ea5f38f2232e77d22b57be096b1281df90d29f.tar.bz2
Adds dangling-archive
-rwxr-xr-xdangling-archive30
1 files changed, 30 insertions, 0 deletions
diff --git a/dangling-archive b/dangling-archive
new file mode 100755
index 0000000..babe4d6
--- /dev/null
+++ b/dangling-archive
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# Archive dangling files.
+#
+
+# Parameters
+DATE="`date +%Y%m%d%I%M%S`"
+LOAD="$HOME/load"
+IMAGES="$HOME/data/images/incoming"
+IMAGES_PATTERN=".*\.(png|jpg|jpeg|gif|svg)"
+DOC="$HOME/data/doc/incoming"
+DOC_PATTERN=".*\.(txt|doc|docx|rtf|pdf|sxc|csv|epub|mobi|djvu)"
+FIND_OPTS="-regextype posix-egrep -iregex"
+
+# Ensure all folders exist
+mkdir -p $LOAD $IMAGES $DOC
+
+# Move images
+if [ "`find $LOAD/ $FIND_OPTS "$IMAGES_PATTERN" | wc -l`" != "0" ]; then
+ echo "Moving images into $IMAGES/$DATE ..."
+ mkdir -p $IMAGES/$DATE
+ find $LOAD/ $FIND_OPTS "$IMAGES_PATTERN" -exec mv {} $IMAGES/$DATE/ \;
+fi
+
+# Move doc
+if [ "`find $LOAD/ $FIND_OPTS "$DOC_PATTERN" | wc -l`" != "0" ]; then
+ echo "Moving docs into $DOC/$DATE ..."
+ mkdir -p $DOC/$DATE
+ find $LOAD/ $FIND_OPTS "$DOC_PATTERN" -exec mv {} $DOC/$DATE/ \;
+fi