Page 1 of 1

Rename format - based on last char?

Posted: 13 Sep 2014, 15:30
by Mech_Man
I keep track of which shows I've watched by appending an underscore character "_" to the file name.

During renaming, is there a way to check if the last character is a "_" and base the renaming format on the result?

EXAMPLE Original name, Unwatched:
Secrets.of.the.Dead.13x5.The.Mona.Lisa.Mystery.hdtv.msd.mkv
Original name, Watched:
Secrets.of.the.Dead.13x5.The.Mona.Lisa.Mystery.hdtv.msd_.mkv

FYI: current renaming code:
{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)} - {'s'+s.pad(2)+'e'+e.pad(2)} - {t.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)} ({airdate.format("yyyy-MM-dd")} @{info.runtime}min {vf}{'-'+source}{'_'+group})

Renamed, Unwatched:
Secrets of the Dead - s13e05 - Mona Lisa Mystery, The (2014-07-09 @60min 480p-HDTV_mSD).mkv

I'd like FileBot to detect if the last character (excluding extension) is a "_",
if so, rename based on my current code but also append an "_"
if not, rename based on my current code.

Renamed, Watched:
Secrets of the Dead - s13e05 - Mona Lisa Mystery, The (2014-07-09 @60min 480p-HDTV_mSD)_.mkv

This question also applies to files that I have already renamed, and watched-tagged as I'm still tweaking my rename format.
It would be nice to be able to take files that were previously renamed & watched and rename them again using the adjusted format.

Re: Rename format - based on last char?

Posted: 13 Sep 2014, 16:11
by rednoah
I'd do it like this:

Code: Select all

{fn[-1].match(/_/)}
Or this:

Code: Select all

{fn =~ /_$/ ? 'WATCHED' : 'NOT WATCHED'}