Rename files using regular expression in linux

后端 未结 7 1435
北恋
北恋 2020-12-04 14:03

I have a set of files named like:

Friends - 6x03 - Tow Ross\' Denial.srt
Friends - 6x20 - Tow Mac and C.H.E.E.S.E..s         


        
7条回答
  •  一个人的身影
    2020-12-04 14:47

    You forgot a dot in front of the asterisk:

    rename -n 's/(\w+) - (\d{1})x(\d{2}).*$/S0$2E$3\.srt/' *.srt
    

    On OpenSUSE, RedHat, Gentoo you have to use Perl version of rename. This answer shows how to obtain it. On Arch, the package is called perl-rename.

提交回复
热议问题