Showing posts with label ZMV. Show all posts
Showing posts with label ZMV. Show all posts

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

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.

Monday, November 23, 2015

Using ZSH ZMV To Mass Rename Files Episodes

This presumes you are in the show folder looking at all the season folders AND the shows have the following format:
### - Episode Title.mkv
zmv 'Season (*)/([0-9])(*) - (*).mkv' 'Season $1/{showtitle} - S0$2E$3 - $4.mkv'
This should leave you with:

Showtitle - S01E01 - Episode Title.mkv

...and so forth.

If you are unsure, add the -n flag to zmv and it will present you the changes versus simply making them.

Note: Replace {$showtitle} with the title of your show. Nested directories with zmv gave me trouble so consider this the one bit of lifting required to save you a bunch of time.