#!/bin/bash
#Filen
ame:
rename_photo.sh
set -x
count=1
for
img in *.
jpg *.png
do
new=image-$count.${img##*.}
mv "$img" "$new" 2> /dev/null
if [ $? -eq 0 ]
then
echo "Renam
eing $img to $new"
let count++
fi
done
[
root@localhost script]# rename image photo image*
将当前目录下所有以image开头的文件,换成以photo开关
[root@localhost rename]# ls
image_1.jpg&nbs
p; image_2.jpg image_3.jpg image_4.jpg image_5.jpg
[root@localhost rename]# rename image photo image*
[root@localhost rename]# ls
photo_1.jpg photo_2.jpg photo_3.jpg photo_4.jpg photo_5.jpg
将扩展名小写的.jpg
改为大写.JPG
[root@localhost rename]# rename .jpg .JPG *.jpg
[root@localhost rename]# ls
photo_1.JPG photo_2.JPG photo_3.JPG photo_4.JPG photo_5.JPG