How can I easily bulk rename files with Perl?

后端 未结 9 1263
一生所求
一生所求 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:46

    In my debian it works well with rename, tested with 300 files.

     perl -e 'map `touch door$_.txt`, 1..300;'
     rename 's/(\d+)\.txt/sprintf("%03d.txt", $1)/e' *.txt
    

提交回复
热议问题