summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xautomv.sh15
-rw-r--r--readme.txt4
2 files changed, 5 insertions, 14 deletions
diff --git a/automv.sh b/automv.sh
index fae371e..c5d496a 100755
--- a/automv.sh
+++ b/automv.sh
@@ -18,23 +18,14 @@ function extract {
grep "^${prop}=.*$" $file | cut -d '=' -f2
}
-function fn_find {
- find $1 -type f \( -regex "${2}" ! -iname ".*" \)
-}
-
function automv {
local query=$1
local source=$2
local target=$3
- file_cnt=$(fn_find $source $query | wc -l)
- if [[ $file_cnt > 0 ]]; then
- echo "Moving $file_cnt files in $source that match '$query' to $target"
- fn_find $source $query
- fn_find $source $query | xargs -I '{}' mv {} $target/
- else
- echo "No files matching '$query' in $source"
- fi
+ echo "Moving files from $source matching '$query' to $target"
+ find $source -type f \( -regex "${query}" ! -iname ".*" \) \
+ | xargs -I '{}' mv -v {} $target/
}
echo "Executing automv functions from $automvdir"
diff --git a/readme.txt b/readme.txt
index c2f5cfa..fa0cd78 100644
--- a/readme.txt
+++ b/readme.txt
@@ -53,8 +53,8 @@ target=/home/user/Pictures/
Nice to haves / Tasks to be done
================================
-[ ] Better logging (timestamps n such) - we repeat the find like 3 times to be
- able to get better logs / printing
+[x] Better logging of moves - we repeat the find like 3 times to be
+[ ] Timestamps in logs?
[ ] More flexibility / configurability
[ ] Fault tolerance
[ ] Auto mkdir -p if the target dir doesn't exist?