批量重命名文件

1.

[lengyuex@Tux 2009-6-21]$ ls
IMG_0478.jpg  IMG_0493.jpg  IMG_0507.jpg  IMG_0523.jpg  IMG_0541.jpg
IMG_0479.jpg  IMG_0494.jpg  IMG_0510.jpg  IMG_0524.jpg  IMG_0542.jpg
IMG_0483.jpg  IMG_0496.jpg  IMG_0512.jpg  IMG_0525.jpg  IMG_0543.jpg
IMG_0489.jpg  IMG_0498.jpg  IMG_0515.jpg  IMG_0526.jpg
IMG_0490.jpg  IMG_0500.jpg  IMG_0516.jpg  IMG_0530.jpg
IMG_0491.jpg  IMG_0503.jpg  IMG_0520.jpg  IMG_0532.jpg
IMG_0492.jpg  IMG_0504.jpg  IMG_0521.jpg  IMG_0537.jpg
[lengyuex@Tux 2009-6-21]$ for i in *;do mv $i `basename $i .jpg`.JPG;done
[lengyuex@Tux 2009-6-21]$ ls
IMG_0478.JPG  IMG_0493.JPG  IMG_0507.JPG  IMG_0523.JPG  IMG_0541.JPG
IMG_0479.JPG  IMG_0494.JPG  IMG_0510.JPG  IMG_0524.JPG  IMG_0542.JPG
IMG_0483.JPG  IMG_0496.JPG  IMG_0512.JPG  IMG_0525.JPG  IMG_0543.JPG
IMG_0489.JPG  IMG_0498.JPG  IMG_0515.JPG  IMG_0526.JPG
IMG_0490.JPG  IMG_0500.JPG  IMG_0516.JPG  IMG_0530.JPG
IMG_0491.JPG  IMG_0503.JPG  IMG_0520.JPG  IMG_0532.JPG
IMG_0492.JPG  IMG_0504.JPG  IMG_0521.JPG  IMG_0537.JPG
2.
[lengyuex@Tux 2009-6-21]$ for i in *;do mv $i `echo $i|sed 's/\.JPG$/.jpg/'`;done
[lengyuex@Tux 2009-6-21]$ ls
IMG_0478.jpg  IMG_0493.jpg  IMG_0507.jpg  IMG_0523.jpg  IMG_0541.jpg
IMG_0479.jpg  IMG_0494.jpg  IMG_0510.jpg  IMG_0524.jpg  IMG_0542.jpg
IMG_0483.jpg  IMG_0496.jpg  IMG_0512.jpg  IMG_0525.jpg  IMG_0543.jpg
IMG_0489.jpg  IMG_0498.jpg  IMG_0515.jpg  IMG_0526.jpg
IMG_0490.jpg  IMG_0500.jpg  IMG_0516.jpg  IMG_0530.jpg
IMG_0491.jpg  IMG_0503.jpg  IMG_0520.jpg  IMG_0532.jpg
IMG_0492.jpg  IMG_0504.jpg  IMG_0521.jpg  IMG_0537.jpg

3.
[lengyuex@Tux 2009-6-21]$ for i in *;do mv $i "${i/\.jpg/.JPG}";done
[lengyuex@Tux 2009-6-21]$ ls
IMG_0478.JPG  IMG_0493.JPG  IMG_0507.JPG  IMG_0523.JPG  IMG_0541.JPG
IMG_0479.JPG  IMG_0494.JPG  IMG_0510.JPG  IMG_0524.JPG  IMG_0542.JPG
IMG_0483.JPG  IMG_0496.JPG  IMG_0512.JPG  IMG_0525.JPG  IMG_0543.JPG
IMG_0489.JPG  IMG_0498.JPG  IMG_0515.JPG  IMG_0526.JPG
IMG_0490.JPG  IMG_0500.JPG  IMG_0516.JPG  IMG_0530.JPG
IMG_0491.JPG  IMG_0503.JPG  IMG_0520.JPG  IMG_0532.JPG
IMG_0492.JPG  IMG_0504.JPG  IMG_0521.JPG  IMG_0537.JPG
4.
[lengyuex@Tux 2009-6-21]$ for f in `find *`;do mv "$f" "`echo "$f"|tr A-Z a-z`";done
[lengyuex@Tux 2009-6-21]$ ls
img_0478.jpg  img_0493.jpg  img_0507.jpg  img_0523.jpg  img_0541.jpg
img_0479.jpg  img_0494.jpg  img_0510.jpg  img_0524.jpg  img_0542.jpg
img_0483.jpg  img_0496.jpg  img_0512.jpg  img_0525.jpg  img_0543.jpg
img_0489.jpg  img_0498.jpg  img_0515.jpg  img_0526.jpg
img_0490.jpg  img_0500.jpg  img_0516.jpg  img_0530.jpg
img_0491.jpg  img_0503.jpg  img_0520.jpg  img_0532.jpg
img_0492.jpg  img_0504.jpg  img_0521.jpg  img_0537.jpg

抛砖引玉。

你可能感兴趣的:(文件)