shell批量重命令文件脚本

批量重命名脚步记录,以备用

假如有一批11.txt 12.txt 13,txt 14.txt 15.txt脚步要要重命名为1.txt 2.txt 3.txt ....

脚本如下:

#!/bin/bash
count=1
for i in *.txt
do
 new=$count.${i#*.}
 mv $i $new
 if [ $? -eq 0 ]
  then echo "renaming $i to $new"
  let count++
 fi
done
原文地址:https://www.cnblogs.com/landhu/p/4962605.html