Page 1 of 1

[SNIPPET] Sort into A-Z folders

Posted: 31 Aug 2013, 08:01
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 }

Re: [SNIPPET] Sort into A-Z folders

Posted: 18 Sep 2021, 14:41
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/)}

Re: [SNIPPET] Sort into A-Z folders

Posted: 18 Sep 2021, 14:55
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

Re: [SNIPPET] Sort into A-Z folders

Posted: 18 Sep 2021, 15:10
by rednoah
e.g.

Code: Select all

{ n =~ /^\d/ ? 'A-Z' : n[0] }

Re: [SNIPPET] Sort into A-Z folders

Posted: 18 Sep 2021, 16:29
by jchh
that's fantastic - thanks.

how do I either/or that with my snippet?

Re: [SNIPPET] Sort into A-Z folders

Posted: 18 Sep 2021, 16:32
by rednoah
e.g.

Code: Select all

{ n =~ /^\d/ ? 'A-Z' : n.replaceFirst(/(?i)(The |A |An |)(.).*/, /$2/) }

Re: [SNIPPET] Sort into A-Z folders

Posted: 18 Sep 2021, 16:42
by jchh
Brilliant - thanks for your help!

Re: [SNIPPET] Sort into A-Z folders

Posted: 07 Nov 2021, 18:24
by JALinker
Is there a way to sort on names minus "The"?

IE Sorted or filed or renamed as "Big Lebowski, The" as opposed to "The Big..."

Lots of "The" movies in my collection I would rather sort differently...

Re: [SNIPPET] Sort into A-Z folders

Posted: 07 Nov 2021, 20:00
by rednoah
JALinker wrote: 07 Nov 2021, 18:24 Is there a way to sort on names minus "The"?
:arrow: [SNIPPET] Sort Name