Automate renaming of video files

后端 未结 4 2107
再見小時候
再見小時候 2021-01-16 13:01

I have a lot of files I want to rename and it would take me a long time to do them manually. They are video files and are usually in this format - \"NAME OF SHOW - EPISODE N

4条回答
  •  不知归路
    2021-01-16 13:39

    Using the perl rename implementation which easily can take care of proper padding and works for any number of seaons and episodes (<100, but can easily be adapted to your current format):

    $ ls -1 *.avi
    My Show - 0301 - Qux.avi
    My Show - 101 - Foo.avi
    My Show - 102 - Bar.avi
    My Show - 1102 - Blah.avi
    My Show - 201 - Quux.avi
    
    $ rename -n 's/- (\d+)(\d{2,}) -/sprintf("- S%02dE%02d -", $1, $2)/e' *.avi
    My Show - 0301 - Qux.avi renamed as My Show - S03E01 - Qux.avi
    My Show - 101 - Foo.avi renamed as My Show - S01E01 - Foo.avi
    My Show - 102 - Bar.avi renamed as My Show - S01E02 - Bar.avi
    My Show - 1102 - Blah.avi renamed as My Show - S11E02 - Blah.avi
    My Show - 201 - Quux.avi renamed as My Show - S02E01 - Quux.avi
    

    I think homebrew ships with the correct version, so it's just a matter of installing via

    $ brew install rename
    

提交回复
热议问题