有一个很好的重命名实用程序,它随 Perl 的安装一起提供。如何在 Perl 正则表达式中附加一个计数器?这是一个相关问题,例如当前目录中的文件编号问题:
rename 's/^/<here I'd like to have a number of a file being processed>/g' *
例如如何重命名:
fileA
fileB
fileC
到
1 - fileA
2 - fileB
3 - fileC
编辑:
我添加了计数器功能($c
变量) - 请参见此处。它工作正常 - 但是当我尝试指定计数器格式时:
rename_c.pl -c 5.2f 's/^/$c - /' *
它说:
Useless use of concatenation (.) or string in void context at line 120.
它并没有真正使用我告诉它使用的格式。这一定是第 120 行中的一些简单语法错误。你能看一下吗?