diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2019-01-18 14:09:04 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2019-01-18 14:09:04 -0200 |
commit | 23ea5f38f2232e77d22b57be096b1281df90d29f (patch) | |
tree | f776e54e015fe73591dc050ac285332c922a9ec7 | |
parent | 310d2a7e5a7fb9a7b6e88cb9e40f80ccc82c7a7a (diff) | |
download | scripts-23ea5f38f2232e77d22b57be096b1281df90d29f.tar.gz scripts-23ea5f38f2232e77d22b57be096b1281df90d29f.tar.bz2 |
Adds dangling-archive
-rwxr-xr-x | dangling-archive | 30 |
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 |