批量重命名与ID转移?

我需要批量重命名一堆名为id的文件,为id添加一个常数

-xxx.txt => -yyy.txt 

任何想法如何制作它? 有些awk也许?

 constant=42 for f in *.txt; do # choose your pattern as appropriate. IFS='-.' read id suffix ext <<< "$f" newname="$(( 10#$id + constant ))-yyy.$ext" echo mv "$f" "$newname" done 

我在算术表达式中添加了“10#”,以确保将数字视为基数10,即使它以零开头也是如此。

如果这不符合您的需求,请在问题中提供更多要求。