From 937fb11d99d88a43db143b15ec9781fd711a65f7 Mon Sep 17 00:00:00 2001 From: desktop Date: Wed, 8 Nov 2023 02:37:05 +0300 Subject: [PATCH] name : stop using dots in names. --- .linux/bash/module/name.sh | 11 ++++++++++- .linux/bash/module/parse.sh | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.linux/bash/module/name.sh b/.linux/bash/module/name.sh index 6f3efb5..3d1c078 100644 --- a/.linux/bash/module/name.sh +++ b/.linux/bash/module/name.sh @@ -18,7 +18,16 @@ name() ((count++)) # parse new name. - local new_name=$(parse_simplify "${target}") + local ext="" + local name="${target}" + + # ext only for files. + if [[ -f "${target}" ]]; then + ext=".${target##*.}" + name="${target%.*}" + fi + + local new_name=$(parse_simplify "${name}")${ext} # status line. local status="[${count}/${total}] ${target} -> ${new_name}" diff --git a/.linux/bash/module/parse.sh b/.linux/bash/module/parse.sh index ad4d6d2..41d9554 100644 --- a/.linux/bash/module/parse.sh +++ b/.linux/bash/module/parse.sh @@ -4,9 +4,9 @@ parse_simplify() { echo "${*}" | \ sed -e "s/ /_/g" \ - -e "s/[^[:alnum:]\._-]//g" \ - -e "s/_\+/_/g" -e "s/\.\+/\./g" -e "s/-\+/-/g" \ - -e "s/_-/_/g" -e "s/-_/_/g" -e "s/\.-/\./g" -e "s/-\./\./g" -e "s/\._/\./g" -e "s/_\./\./g" \ + -e "s/[^[:alnum:]_-]//g" \ + -e "s/_\+/_/g" -e "s/-\+/-/g" \ + -e "s/_-/_/g" -e "s/-_/_/g" \ -e "s/_\+/_/g" \ -e "s/^_//" -e "s/_$//" }