2012. 7. 12. 17:26

DIR="/test/"
HEAD="2002년_월드컵응원_"
FOOT=".jpg"
A=`ls $DIR`
NUM=1

for i in `echo $A`
do
    if [ "$NUM" -lt 10 ];then
        mv ${DIR}$i ${DIR}${HEAD}000${NUM}${FOOT}

    elif [ "$NUM" -ge 10 -a "$NUM" -lt 100 ]; then
        mv ${DIR}$i ${DIR}${HEAD}00${NUM}${FOOT}

    elif [ "$NUM" -ge 100 -a "$NUM" -lt 1000 ]; then
        mv ${DIR}$i ${DIR}${HEAD}0${NUM}${FOOT}

    elif [ "$NUM" -ge 1000 ]; then
        mv ${DIR}$i ${DIR}${HEAD}${NUM}${FOOT}
    fi

    NUM=`expr $NUM + 1`
done

Posted by 몰라욧