Rename format - based on last char?

Any questions? Need some help?
Post Reply
User avatar
Mech_Man
Posts: 21
Joined: 31 Oct 2012, 16:19

Rename format - based on last char?

Post 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.
Duct tape is like the Force. It has a light side, a dark side, and it holds the Universe together
User avatar
rednoah
The Source
Posts: 20927
Joined: 16 Nov 2011, 08:59

Re: Rename format - based on last char?

Post by rednoah »

I'd do it like this:

Code: Select all

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

Code: Select all

{fn =~ /_$/ ? 'WATCHED' : 'NOT WATCHED'}
:idea: Please read the FAQ and How to Request Help.
Post Reply