How can I easily bulk rename files with Perl?

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

    you could do something using perl or ruby.

    put all this files in the same directory

    dirlisting = DIR.entries('.')
    
    dirListing.each do |file| 
     num = file.match(/\d+$/).to_i
     if num < 100
       find the position where start the number, with index and inject the 0 there.
     end
    end
    

提交回复
热议问题