我在一个目录中有多个顺序文件命名,具有多个增量文件扩展名。我的目标是使用重命名命令重命名文件扩展名。
IBM0020.DAT_001
IBM0020.DAT_002
IBM0020.DAT_003
IBM0021.DAT_001
IBM0021.DAT_002
IBM0022.DAT_001
IBM0022.DAT_002
IBM0022.DAT_003
IBM0022.DAT_004
...
到
IBM0020.DAT_001
IBM0020.DAT_002
IBM0020.DAT_003
IBM0021.DAT_004
IBM0021.DAT_005
IBM0022.DAT_006
IBM0022.DAT_007
IBM0022.DAT_008
IBM0022.DAT_009
...
我已经试运行了下面的命令,但不是预期的结果。我想保留文件名,只重命名/更改带有运行编号序列的扩展名。
rename -n 's/.+/our $i;sprintf(".DAT_%03d",1+$i++)/e' *
IBM0020.DAT_001 renamed as .DAT_001
IBM0020.DAT_002 renamed as .DAT_002
IBM0020.DAT_003 renamed as .DAT_003
IBM0021.DAT_001 renamed as .DAT_004
IBM0021.DAT_002 renamed as .DAT_005
IBM0022.DAT_001 renamed as .DAT_006
IBM0022.DAT_002 renamed as .DAT_007
IBM0022.DAT_003 renamed as .DAT_008
IBM0022.DAT_004 renamed as .DAT_009
谢谢你的帮助。