Collection Index via {model}

All about user-defined episode / movie format expressions
Post Reply
User avatar
rednoah
The Source
Posts: 15958
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Collection Index via {model}

Post by rednoah » 03 Dec 2018, 08:14

:idea: FileBot 4.8.5 introduces the new {ci} collection index binding, which makes things work easily out of the box.


If you use {collection} to organize movies by movie collection, then you will find that many movie collections don't show in order if you sort the {ny} filename alphabetically.

If you process all entries of a collection in one go, then you can use the {model} binding to compute the movie number within a given collection.

Code: Select all

{model.findAll{ it.collection == collection }.sort{ it.d }.findIndexOf{ it.id == id } + 1}
  • Access all bindings for all matches via {model}
  • Find all matches where the collection matches the collection of the movie we're currently formatting
  • Sort by release date
  • Find index of movie that matches the movie we're currently formatting
  • Plus 1 because index starts at 0

e.g.

Code: Select all

The Girl With The Dragon Tattoo (2009)
The Girl Who Played With Fire (2009)
The Girl Who Kicked The Hornet's Nest (2009)

Code: Select all

{collection}/{model.findAll{ it.collection == collection }.sort{ it.d }.findIndexOf{ it.id == id } + 1}. {plex.name}

Code: Select all

The Millennium Collection/1. The Girl with the Dragon Tattoo (2009)
The Millennium Collection/2. The Girl Who Played with Fire (2009)
The Millennium Collection/3. The Girl Who Kicked the Hornet's Nest (2009)
:idea: Please read the FAQ and How to Request Help.

Post Reply