diff options
author | xyz <gky44px1999@gmail.com> | 2021-10-05 17:40:22 -0700 |
---|---|---|
committer | xyz <gky44px1999@gmail.com> | 2021-10-05 17:40:22 -0700 |
commit | 3161b11eda69fffb25bd0fc084dcf8a0052c6d82 (patch) | |
tree | 6d9682d94c80a22285d4379ae1a77db92c64f582 | |
parent | 894f50884c916db4187093bcfd1711caea745e7e (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 1e0bfb05..9f0f680d 100755 --- a/.local/bin/mvtr +++ b/.local/bin/mvtr @@ -7,4 +7,7 @@ # 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)}' \; +find "$@" -depth -execdir sh -c 'mv -nvT -- "$2" "$(echo "$2" | awk "$1" )"' shell '{gsub(/\/-+/,"/");gsub(/ +/,"_");gsub(/_*-+_*/,"-");print tolower($0)}' '{}' \; + +# 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/ |