How can I easily bulk rename files with Perl?

后端 未结 9 1211
一生所求
一生所求 2021-01-05 17:25

I have a lot of files I\'m trying to rename, I tried to make a regular expression to match them, but even that I got stuck on the files are named like:

<
9条回答
  •  长发绾君心
    2021-01-05 17:52

    Run two commands, in this order:

    $ rename 's/File Name (\d)$/File Name 0$1/' *
    $ rename 's/File Name (\d\d)$/File Name 0$1/' *
    

    First one renames everything less than 10 and prepends a zero. The second one renames everything less than 100 and prepends a zero. The result should be three digits for all filenames.

提交回复
热议问题