批量更改文件名:
1、在多个文件后面添加.bak或者其他有规律的字符
ls |xargs -n1 -i{} mv {} {}.bak
或者
find ./*.txt -exec mv {} {}_bak \;
2、通用的批量更改脚本
#!/bin/bash
read -p "old extension:" oldext
read -p "new extension:" newext
read -p "The directory:" dir
cd $dirfor file in $(ls $dir | grep .$oldext)
        do
        name=$(ls $file | cut -d. -f1)
        #或者直接用sed替换
        #name=$(echo $file |sed ‘s/oldpattern/newpattern/g‘)
        #mv $file $name
        mv $file ${name}.$newext
        echo "$name.$oldext ====> $name.$newext"
        done
echo "all files has been modified."本文出自 “DanielQu” 博客,请务必保留此出处http://qujunorz.blog.51cto.com/6378776/1639849
原文地址:http://qujunorz.blog.51cto.com/6378776/1639849