Batch rename sequential files by padding with zeroes

后端 未结 8 1197
天命终不由人
天命终不由人 2020-12-08 02:42

I have a bunch of files named like so:

output_1.png
output_2.png
...
output_10.png
...
output_120.png

What is the easiest way of renaming t

8条回答
  •  悲&欢浪女
    2020-12-08 03:01

    For mass renaming the only safe solution is mmv—it checks for collisions and allows renaming in chains and cycles, something that is beyond most scripts. Unfortunately, zero padding it ain't too hot at. A flavour:

    c:> mmv output_[0-9].png output_000#1.png
    

    Here's one workaround:

    c:> type file
    mmv
    [^0-9][0-9] #1\00#2
    [^0-9][0-9][^0-9] #1\00#2#3
    [^0-9][0-9][0-9] #1\0#2#3
    [^0-9][0-9][0-9][^0-9] #1\0#2#3
    c:> mmv 

提交回复
热议问题