Plex Naming Schemes

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

Plex Naming Schemes

Post by rednoah » 12 Sep 2016, 10:03

Plex Naming Standard

Plex has strict standards for naming and organizing your media files.

Code: Select all

Movies/Avatar (2009)/Avatar (2009)
TV Shows/Alias/Season 01/Alias - S01E01 - Truth Be Told
The {plex} binding which will give you the appropriate Plex path for movies, TV episodes, Anime episodes and music files:

Code: Select all

{plex}
:idea: Make sure to Disable Local Media Assets for all your media libraries to make Plex not give preference to the embedded media title.


Since the {plex} binding will give you a File object, it's easy to reuse some path components and omit others. {plex.name} and {plex.tail} are particularly useful if you want to rename files in place or if you want the {plex} path without the top-level Movies or TV Shows folder.

e.g. Avatar (2009)

Code: Select all

{plex.name}
e.g. Firefly/Season 01/Firefly - S01E01 - Serenity

Code: Select all

{plex.tail}
e.g. Firefly/Firefly - S01E01 - Serenity

Code: Select all

{plex[1]}/{plex[3]}
e.g. Movies/Avatar (2009)/Avatar (2009) by James Cameron [720p, x264, AC3].eng

Code: Select all

{plex.derive{" by $director"}{" [$vf, $vc, $ac]"}}
:idea: plex.derive() can be used to insert additional information after the file name but before the subtitle language suffix and file extension.


Image



Kodi Naming Standard

The {kodi} binding and the {plex} binding work exactly the same, with slightly different implementation details, e.g. SxE formatting and multi-episode formatting.



Custom Naming Schemes

If you need to make very specific customizations to the standard Plex naming scheme, you'll want you write your own format expression so you have full control over all the bits and pieces. You can get started by copying the following examples and modifying them to your liking.

Movies

Code: Select all

Movies/{n} ({y})/{n} ({y}){' CD'+pi}{'.'+lang}
TV Series

Code: Select all

TV Shows/{n}/{episode.special ? 'Specials' : 'Season '+s.pad(2)}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t.replaceAll(/[`´‘’ʻ]/, /'/).replaceAll(/[!?.]+$/).replacePart(', Part $1')}{'.'+lang}
Anime

Code: Select all

Anime/{primaryTitle}/{primaryTitle} - {sxe} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, /'/).replacePart(', Part $1')}
Music

Code: Select all

Music/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}
:idea: Please read the FAQ and How to Request Help.

Gruff10
Posts: 2
Joined: 21 Jan 2019, 21:41

Re: Plex Naming Schemes

Post by Gruff10 » 21 Jan 2019, 21:57

Hi,

NOOB here :?

Using

Code: Select all

{plex.derive{" [$vf.$vc.$ac]"}}
I find that the TV series 24 (Twenty Four) fails because the fullstops in its episode titles are being replaced (see output below).

https://ibb.co/87vTcrF

How can I get around this?

Thanks.

User avatar
rednoah
The Source
Posts: 17861
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex Naming Schemes

Post by rednoah » 22 Jan 2019, 05:12

Yes, the {plex} format does indeed strip trailing "." characters from the Plex path. In your case, that's unnecessary, but the {plex} binding can't know that.

e.g.

Code: Select all

$ filebot -list --q 24 --format {plex} --filter "s == 1 && e <= 3"
TV Shows/24/Season 01/24 - S01E01 - 12.00 A.M. - 1.00 A.M
TV Shows/24/Season 01/24 - S01E02 - 1.00 A.M. - 2.00 A.M
TV Shows/24/Season 01/24 - S01E03 - 2.00 A.M. - 3.00 A.M

If want to preserve the trailing "." then you can use a full custom format such as this:

Code: Select all

TV Shows/{n}/Season {s.pad 2}/{n} - {s00e00} - {t} [{vf}.{vc}.{ac}]
:idea: Please read the FAQ and How to Request Help.

Gruff10
Posts: 2
Joined: 21 Jan 2019, 21:41

Re: Plex Naming Schemes

Post by Gruff10 » 22 Jan 2019, 12:06

Thanks. That worked, though the ":"s in the episode titles are a pain as well. At least the Validate button clears them ;)

User avatar
rednoah
The Source
Posts: 17861
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex Naming Schemes

Post by rednoah » 22 Jan 2019, 14:06

Additional customizations like this will do the job:

Code: Select all

{n.colon(' - ')}

The {plex} format does take care of these corner cases already, and if you need all of those but if you want more control, then you can start with a format such as this, and then modify it to your needs:

Code: Select all

TV Shows/{n}/{episode.special ? 'Specials' : 'Season '+s.pad(2)}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t.replaceAll(/[`´‘’ʻ]/, /'/).replaceAll(/[!?.]+$/).replacePart(', Part $1')}{'.'+lang}
:idea: The .replaceAll(/[!?.]+$/) bit is responsible for removing trailing !?. so you could just cut that bit.
:idea: Please read the FAQ and How to Request Help.

Kopernikus
Posts: 5
Joined: 03 Feb 2019, 20:07

Re: Plex Naming Schemes

Post by Kopernikus » 07 Feb 2019, 14:11

Hi,

If I use:

Code: Select all

{plex.derive {" [$vf.$vc.$ac]"}}
I get

Code: Select all

/volume1/video/Movies/xXx (2002)/xXx (2002) [480p.x264.AC3].mkv
but how to I get

Code: Select all

/volume1/video/Movies/xXx (2002) [480p.x264.AC3]/xXx (2002) [480p.x264.AC3].mkv
or

Code: Select all

/volume1/video/Movies/xXx (2002) [480p.x264.AC3]/xXx (2002).mkv
I want to use the Plex format, but to now the video format so I now for example when I replace a SD by HD version of the same movie.

Thx

User avatar
rednoah
The Source
Posts: 17861
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex Naming Schemes

Post by rednoah » 07 Feb 2019, 14:38

There's no convenience method for this particular use case.

You'll either have to
(A) write your own custom format without using the {plex} binding at all, or
(B) write your own custom format using bits and pieces of the {plex} binding as necessary.

e.g.

Code: Select all

Movies/{plex[1]}{" [$vf.$vc.$ac]"}/{plex[2]}{" [$vf.$vc.$ac]"}

:!: Either way, you'll no longer be strictly adhering to the Plex naming scheme, although it'll probably work.
:idea: Please read the FAQ and How to Request Help.

guyrivera
Posts: 1
Joined: 06 Dec 2019, 04:19

Re: Plex Naming Schemes

Post by guyrivera » 06 Dec 2019, 04:22

rednoah wrote:
07 Feb 2019, 14:38
There's no convenience method for this particular use case.

You'll either have to
(A) write your own custom format without using the {plex} binding at all, or
(B) write your own custom format using bits and pieces of the {plex} binding as necessary.

e.g.

Code: Select all

Movies/{plex[1]}{" [$vf.$vc.$ac]"}/{plex[2]}{" [$vf.$vc.$ac]"}

:!: Either way, you'll no longer be strictly adhering to the Plex naming scheme, although it'll probably work.
Thanks a lot - it works!

fud18
Posts: 4
Joined: 04 Feb 2020, 16:45

Re: Plex Naming Schemes

Post by fud18 » 05 Feb 2020, 16:25

I recently noticed that some of my movies were not getting their meta data in Plex unless I manually matched the titles. What I noticed was preventing this was having A|An|The at the beginning. According to Plex's website/forums if you place anything after a parenthesis it will not detect it which allows the files to match correctly. Below are the naming formats I have tried with examples. Any help would be greatly appreciated to get my naming to work like Example 3.
Example 1:
  • The Fly (1986) is matched correctly in Plex, but I want proper sort with the The at the end
    Filebot naming script: {n.replace(':',' - ')} ({y})
Example 2:
  • Fly, The (1986) is not matched correctly in Plex.
    Filebot naming script: {n.sortName('$2, $1').replace(':',' - ')} ({y})
Example 3 (What I would like): Fly (1986), The
  • If the current file does not begin with "A|An|The" the naming is done incorrectly as such
    Hamburger: The Motion Picture (1986) = Hamburger: The Motion Picture (1986), Hamburger: The Motion Picture
    The Fly (1986) = Fly (1986), The
    Filebot naming script: {n.sortName('$2').replace(':',' - ')} ({y}){n.sortName(', $1').replace(':',' - ')}

User avatar
rednoah
The Source
Posts: 17861
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex Naming Schemes

Post by rednoah » 05 Feb 2020, 16:43

AFAIK, what you would like is is not what Plex would like to see:
https://support.plex.tv/articles/categories/your-media/

:idea: {plex} is the way to go. It may not be what you want, but it'll be what Plex wants and expects. You can do things differently, and maybe it'll mostly work, or maybe it'll sometimes not work, either way, no guarantees once you start ignoring the standard if favor of your own preferences. ;)

Code: Select all

{plex}
:idea: Please read the FAQ and How to Request Help.

fud18
Posts: 4
Joined: 04 Feb 2020, 16:45

Re: Plex Naming Schemes

Post by fud18 » 05 Feb 2020, 16:55

Thanks for the reply rednoah, I have tried that, but I don't want all the A|An|The's lumped together...makes it a real nightmare to try and remove files if I am bouncing around all over the place. I will face the consequences of the way I want it named if someone can just tell me how to the the A|An|The from the beginning of the title to after the date as provided in my example. I have tested it and it works flawlessly that's why I want to do it plus then I can find them easy in windows explorer to remove movies I no longer want.

User avatar
rednoah
The Source
Posts: 17861
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex Naming Schemes

Post by rednoah » 05 Feb 2020, 17:01

You could do n.sortName() to remove the A and The altogether, since that'll probably mess with Plex the least:

Code: Select all

n.sortName()
:idea: Please read the FAQ and How to Request Help.

fud18
Posts: 4
Joined: 04 Feb 2020, 16:45

Re: Plex Naming Schemes

Post by fud18 » 05 Feb 2020, 17:03

But how do I add the removed part back after the (year)?

User avatar
rednoah
The Source
Posts: 17861
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex Naming Schemes

Post by rednoah » 05 Feb 2020, 17:05

Assuming that Plex ignores everything after the Name (Year) part, you can try this:

Code: Select all

ny.sortName('$2, $1')
:idea: Please read the FAQ and How to Request Help.

fud18
Posts: 4
Joined: 04 Feb 2020, 16:45

Re: Plex Naming Schemes

Post by fud18 » 05 Feb 2020, 17:15

That worked like a charm. Thanks so much rednoah!!!!!

Ashaneil
Posts: 3
Joined: 28 Mar 2020, 14:34

Re: Plex Naming Schemes

Post by Ashaneil » 29 Mar 2020, 16:24

Is there a full list of all the {plex} components or is there a way for me to "see" the component choices - kind of like MediaInfo?

User avatar
rednoah
The Source
Posts: 17861
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex Naming Schemes

Post by rednoah » 29 Mar 2020, 16:28

Ashaneil wrote:
29 Mar 2020, 16:24
Is there a full list of all the {plex} components or is there a way for me to "see" the component choices - kind of like MediaInfo?
What components are you looking for?

All components relevant to {plex} are listed as examples here. A large number of properties and methods are inherited from the File class but those are largely irrelevant for {plex} related use cases.

:idea: {plex.properties} can be used see all properties. This is a Groovy thing and applies to all classes and isn't specific to {plex} or the File class.
:idea: Please read the FAQ and How to Request Help.

Post Reply