Thursday, February 22, 2018

Using ZSH ZMV to Force Add Leading Zeros

Given a list of episodes that are named with single digits, but you'd like leading zeros:

S1E1.avi
S1E2.avi
S1E3.avi
S1E4.avi

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

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