name : stop using dots in names.

This commit is contained in:
Dmitry Voronin 2023-11-08 02:37:05 +03:00
parent 1e3afbdebc
commit 937fb11d99
2 changed files with 13 additions and 4 deletions

View file

@ -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}"

View file

@ -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/_$//"
}