批量修改后缀名的bash 脚本

abloz 2008-04-01
2008-04-01
#!/bin/sh
# file name : rename_suffix.sh
# author: zhouhh
# blog: http://blog.csdn.net/ablo_zhou
# Email: ablozhou@gmail.com
# Date : 2008.4.1

echo "input what suffix will be replaced :"
read SUFFIX_SRC
echo "input what suffix of file to rename to:"
read SUFFIX_DST


for i in *.$SUFFIX_SRC
do
    if [ -e $i ]; then
        echo "mv $i to `basename $i .$SUFFIX_SRC`.$SUFFIX_DST"
        mv $i `basename $i .$SUFFIX_SRC`.$SUFFIX_DST
    else
        echo "file does not exist."
        exit -1
    fi

done

如非注明转载, 均为原创. 本站遵循知识共享CC协议,转载请注明来源