1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/bin/bash #fuck the one who yell to me today count=1 for img in *.jpg *.png do new=image-$count.${img##*.} mv "$img" "$new" 2>/dev/null if [ $? eq 0 ];then echo "Renaming $img to $new" let count++ fi done |
关于取后缀的部分,如下例子 URL=”www.google.com” echo ${URL%.*} www.google echo ${URL%%.*} www echo ${URL#*.} ……