diff --git a/document/linux/config/bash/module/name.sh b/document/linux/config/bash/module/name.sh index 46d25a2..e1e61a2 100644 --- a/document/linux/config/bash/module/name.sh +++ b/document/linux/config/bash/module/name.sh @@ -14,28 +14,13 @@ name() # process. for file in $files; do - local extension local new_name # extract new name. - extension="${file##*.}"; - - if [ -f "$file" ] && [ "$extension" != "$file" ]; then - 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" + new_name=$(echo "$file" | \ + sed -e "s/[^[:alnum:]\.-]/_/g" \ + -e "s/_\+/_/g" + ) # status line. local status="[$count/$total] $file -> $new_name"