From bcc561d578ec16ff44b935469fcef8882e8474d5 Mon Sep 17 00:00:00 2001 From: Albert S Date: Thu, 20 Aug 2020 10:46:12 +0200 Subject: [PATCH] Examples: Add download mover --- examples/move_downloads.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 examples/move_downloads.sh diff --git a/examples/move_downloads.sh b/examples/move_downloads.sh new file mode 100755 index 0000000..52918eb --- /dev/null +++ b/examples/move_downloads.sh @@ -0,0 +1,21 @@ +#!/bin/bash +#moves all incoming files (e. g. downloads) to another directory. +#There, they will be put into subdirectories which are named after the current date (YYYYMMDD) to get some minimal automatic "organization". +#adhocify -d -m IN_CLOSE_WRITE -m IN_MOVED_TO -w /home/user/Downloads -w /home/user/other_dir /path/to/move_downloads.sh + +INCOMING="$1" +#ignore partial downloads (.part in firefox, .crdownload in chrome) +echo "$INCOMING" | grep -q .part$ && exit +echo "$INCOMING" | grep -q .crdownload$ && exit +today=$(date +%Y%m%d) +TARGET_DIR="/target/dir/path" +TODAY_DIR="$TARGET_DIR"/$today +if [ ! -d "$TODAY_DIR" ] ; then +mkdir "$TODAY_DIR" +rm -f "$TARGET_DIR"/today +ln -s "$TODAY_DIR" "$TARGET_DIR"/today +fi +#You can also filter/grep the filename here and move certain patterns to other designated locations... +mv "$INCOMING" "$TARGET_DIR"/$today/ + +