summaryrefslogtreecommitdiff
path: root/automv.sh
diff options
context:
space:
mode:
authorSteph Enders <smenders@gmail.com>2022-03-19 14:19:05 -0400
committerSteph Enders <smenders@gmail.com>2022-03-19 14:19:05 -0400
commit0791c354995775becf558f4b0031daf55477f88f (patch)
tree462eddb8344304c37e7e4b8d62f2395f8d3cd21d /automv.sh
parentbeb08521b1cb06aa2c282a6752c7b588326fa025 (diff)
Reduce verbose find queries in favor of mv -v
We can literally use mv -v instead! Why didn't I think to look at the manpage for mv! Lol
Diffstat (limited to 'automv.sh')
-rwxr-xr-xautomv.sh15
1 files changed, 3 insertions, 12 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"