[SNIPPET] Sort into A-Z folders

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

[SNIPPET] Sort into A-Z folders

Post by rednoah »

Here's some formats that can help you sort movies or episodes into alphabetically sorted folders by the first letter.

Sort Movies and TV Shows into A-Z folders:
  • TV Shows/F/Firefly/Season 1/Firefly - S01E01 - The Train Job
  • Movies/S/Serenity (2005)/Serenity (2005)

e.g. The built-in {az} binding works for both Movie and Episode objects:

Code: Select all

{ az }/{ ~plex }

e.g. Custom Series Format:

Code: Select all

{ n =~ /^(?i)[a-z]/ ? n[0] : '#' }/{ plex.name }
e.g. Custom Movie Format:

Code: Select all

{ n =~ /^(?i)[a-z]/ ? n[0] : '#' }/{ plex.name }
:idea: Please read the FAQ and How to Request Help.
jchh
Posts: 39
Joined: 02 Nov 2020, 15:13

Re: [SNIPPET] Sort into A-Z folders

Post by jchh »

I got this to work by myself before realising {az} existed, but... it files "Riddick (2013)" into /C/ (presumably because the 1st film was "The Chronicles of Riddick") so I am not sure if this is a bug or not. I would prefer to file it into /R/.

The second snippet works except movies starting with "A" or "The" etc (filing it into /A/ or /T/ respectfully).

The following worked for me:

Code: Select all

{n.replaceFirst(/(?i)(The |A |An |)(.).*/, /$2/)}
jchh
Posts: 39
Joined: 02 Nov 2020, 15:13

Re: [SNIPPET] Sort into A-Z folders

Post by jchh »

...although I'd like to put films starting with a number (eg: 28 days later) into the folder "A-Z". Any tips on how I could incorporate that into my snippet would be appreciated.

[edit]: that was a typo - I'd want to put in into a folder called 0-9
Last edited by jchh on 18 Sep 2021, 16:34, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 20177
Joined: 16 Nov 2011, 08:59

Re: [SNIPPET] Sort into A-Z folders

Post by rednoah »

e.g.

Code: Select all

{ n =~ /^\d/ ? 'A-Z' : n[0] }
:idea: Please read the FAQ and How to Request Help.
jchh
Posts: 39
Joined: 02 Nov 2020, 15:13

Re: [SNIPPET] Sort into A-Z folders

Post by jchh »

that's fantastic - thanks.

how do I either/or that with my snippet?
User avatar
rednoah
The Source
Posts: 20177
Joined: 16 Nov 2011, 08:59

Re: [SNIPPET] Sort into A-Z folders

Post by rednoah »

e.g.

Code: Select all

{ n =~ /^\d/ ? 'A-Z' : n.replaceFirst(/(?i)(The |A |An |)(.).*/, /$2/) }
:idea: Please read the FAQ and How to Request Help.
jchh
Posts: 39
Joined: 02 Nov 2020, 15:13

Re: [SNIPPET] Sort into A-Z folders

Post by jchh »

Brilliant - thanks for your help!
Post Reply