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