name : simplify process.

This commit is contained in:
Dmitry Voronin 2023-10-24 02:40:45 +03:00
parent 4a070f0de2
commit 5aaa55ca9a

View file

@ -14,28 +14,13 @@ name()
# process. # process.
for file in $files; do for file in $files; do
local extension
local new_name local new_name
# extract new name. # extract new name.
extension="${file##*.}"; new_name=$(echo "$file" | \
sed -e "s/[^[:alnum:]\.-]/_/g" \
if [ -f "$file" ] && [ "$extension" != "$file" ]; then -e "s/_\+/_/g"
new_name="${file%$extension}"
else
new_name="$file"
extension=""
fi
new_name=$(echo "$new_name" | \
sed -e 's/^0\+//g' \
-e 's/[ ,-]\+/_/g' \
-e 's/[][?,:,\!,@,~,&,=,%,+,#,\,,(,),{,}]\+//g' \
-e s/\'//g \
-e 's/_\+/_/g' \
# -e 's/\.\+/_/g' \
) )
new_name="${new_name,,}$extension"
# status line. # status line.
local status="[$count/$total] $file -> $new_name" local status="[$count/$total] $file -> $new_name"