summaryrefslogtreecommitdiff
path: root/.local/bin/mvtr
blob: 1e0bfb0531af62f1004322346275783756594c84 (plain)
1
2
3
4
5
6
7
8
9
10
#!/bin/sh

# can use ls pipe to sed pipe to bash, similar to eval? see comment at link:
# 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

# 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)}' \;