Shell脚本,用法如下
1
./batch_rename.sh FOLDER -old OLD_STR -new NEW_STR
123456789101112131415161718192021
#!/bin/bashfolder=$1if [ ! -d $folder ]; then echo "缺少目录" exit fishiftwhile echo $1 | grep ^- > /dev/null; do eval $( echo $1 | sed 's/-//g' | tr -d '\012')=$2 shift shiftdonefiles=`find ${folder} | grep ${old}`for file in $files; do mv "$file" "${file//${old}/${new}}"done