Thursday, February 22, 2018

Using ZSH ZMV to Rename Split an Episode to Two Episodes

Given a list of episodes that are named to be one, but actually need to span two episodes:

S01E01.avi
S01E02.avi
S01E03.avi
S01E04.avi

zmv 'S([0-9][0-9])E([0-9][0-9]).(*)' 'S$1E${(l:2::0:)$((($2 * 2) - 1))}-E${(l:2::0:)$(($2 * 2))}.$3'
They'd now be renamed as follows:

S01E01-E02.avi
S01E03-E04.avi
S01E05-E06.avi
S01E07-E08.avi

This will also force leading zeros on S and E should they originally be single digits.

No comments:

Post a Comment