diff options
author | xyz <gky44px1999@gmail.com> | 2021-10-06 19:45:55 -0700 |
---|---|---|
committer | xyz <gky44px1999@gmail.com> | 2021-10-06 19:45:55 -0700 |
commit | 30881d30a41db1f41eec47d7c39730c42c525ac9 (patch) | |
tree | 7872b96096556e62e0c9784f967ad0caec9b8c17 | |
parent | 01eb1b93b919f877caeb49d926f06162c05ab406 (diff) |
refactor
-rwxr-xr-x | .local/bin/mvtr | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/.local/bin/mvtr b/.local/bin/mvtr index 38fc5071..3fc9b4cd 100755 --- a/.local/bin/mvtr +++ b/.local/bin/mvtr @@ -8,7 +8,10 @@ # 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 # -exec can't replace -execdir here, see cli notes for the -exec way -find "$@" -depth -execdir sh -c 'mv -nvT -- "$2" "$(echo "$2" | awk "$1" )"' shell '{sub(/\/-+/,"/");gsub(/ +/,"_");gsub(/_*-+_*/,"-");print tolower($0)}' '{}' \; + +find "$@" -depth -execdir sh -c 'mv -nvT -- "$1" "$(echo "$1" | tr "[:upper:] " "[:lower:]_" | tr -s "[:punct:]" | sed -E -e "s#/-#/#g" -e "s/_([-().,])/\1/g" -e "s/([-(),])_/\1/g" | tr -s "[:punct:]")"' shell '{}' \; + +#find "$@" -depth -execdir sh -c 'mv -nvT -- "$1" "$(echo "$1" | tr "[:upper:] " "[:lower:]_" | tr -s "[:punct:]" | sed -E -e "s#/-#/#g" -e "s/_([[:punct:]])/\1/g" -e "s/([[:punct:]])_/\1/g" | tr -s "[:punct:]")"' shell '{}' \; # for test #mkdir -p ~/test/TE\ ST/; rm -rf ~/test/TE\ ST/1t/; cp -r ~/test/0t/ ~/test/TE\ ST/1t/; mvtr ~/test/TE\ ST/1t/; tree ~/test/TE\ ST/1t/ |