filename_extension() {
  for file in "${@-}"; do
    command -p -- printf -- '%s\n' "${file##*.}"
  done
}

filename_without_extension() {
  for file in "${@-}"; do
    # https://overflow.adminforge.de/questions/12152997/placeholder#12152997
    command -p -- basename -- "${file%.*}"
  done
}

filename_spaces_to_underscores() {
  command find -- . \
    -depth \
    -name '*'"${1:-[[:space:]]}"'*' |
    while IFS='' read -r -- file; do
      command -p -- mv -i -- "${file-}" "${file%/*}"/"$(
        command -p -- printf -- '%s' "${file##*/}" |
          command -p -- tr -s -- "${1:-[:space:]}" "${2:-_}"
      )"
    done
}
filename_underscores_to_spaces() {
  command find -- . \
    -depth \
    -name '*_*' |
    while IFS='' read -r -- file; do
      command -p -- mv -i -- "${file-}" "${file%/*}"/"$(
        command -p -- printf -- '%s' "${file##*/}" |
          command -p -- tr -s -- "${1:-_}" "${2:- }"
      )"
    done
}

