name : simplify process.
This commit is contained in:
parent
4a070f0de2
commit
5aaa55ca9a
|
@ -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"
|
||||
|
|
Reference in a new issue