加if判断这样 不满足条件的就不会去处理。或者处理过的就不会再处理。
${i%%.*} 取文件名
${i#*.} 取扩展名
纯小写字母的转大写:
for i in * ; do exp=${i#*.};o=${i%%.*}; if [[ $o =~ ^[a-z]+$ ]];then mv $i $(echo $o|tr [a-z] [A-Z]).$exp; fi; done
连同扩展名:
for i in * ; do exp=${i#*.};o=${i%%.*}; if [[ $o =~ ^[a-z]+$ ]];then mv $i $(echo $o|tr [a-z] [A-Z]).$(echo $exp|tr [a-z] [A-Z]); fi; done
小写字母开头
for i in * ; do exp=${i#*.};o=${i%%.*}; if [[ $o =~ ^[a-z] ]];then mv $i $(echo $o|tr [a-z] [A-Z]).$exp; fi; done
连同扩展名:
for i in * ; do exp=${i#*.};o=${i%%.*}; if [[ $o =~ ^[a-z] ]];then mv $i $(echo $o|tr [a-z] [A-Z]).$(echo $exp|tr [a-z] [A-Z]); fi; done