summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2021-10-05 16:46:35 -0700
committerxyz <gky44px1999@gmail.com>2021-10-05 16:46:35 -0700
commit894f50884c916db4187093bcfd1711caea745e7e (patch)
tree4c3cf0c087fd9d79eff106b7fc25427a29aaa1f5 /.local
parente081f982f431b0e3da5305588067182162cff54d (diff)
mvtr, nawk, consider _-_ __ -- ^-
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/mvtr5
1 files changed, 4 insertions, 1 deletions
diff --git a/.local/bin/mvtr b/.local/bin/mvtr
index d16f1a8d..1e0bfb05 100755
--- a/.local/bin/mvtr
+++ b/.local/bin/mvtr
@@ -4,4 +4,7 @@
# link also show perl-rename approach
# https://linuxconfig.org/rename-all-files-from-uppercase-to-lowercase-characters
# if only change ' ' to '_' `rename` might be sufficient, for upper to lower case might need perl-rename if want concise
-find "$@" -depth -execdir sh -c 'mv -nvT -- "$1" "$(echo "$1" | tr "[:upper:] " "[:lower:]_")"' shell '{}' \;
+
+# pass awk script as argument trick from url:
+# https://unix.stackexchange.com/questions/282503/right-syntax-for-awk-usage-in-combination-with-other-command-inside-xargs-sh-c
+find "$@" -depth -execdir sh -c 'mv -nvT -- "$1" "$(echo "$1" | awk "$2" )"' shell '{}' '{gsub(/\/-+/,"/");gsub(/ +/,"_");gsub(/_*-+_*/,"-");print tolower($0)}' \;