Organise for PLEX

Tags: #<Tag:0x00007f050985b9d8> #<Tag:0x00007f050985b898> #<Tag:0x00007f050985b730>


Hi I’m starting my media server and i would like to organise it as the software vendor recommend to avoid any lost of accurate information on my library. I’m using PLEX and they recommend me to organise my library in this way
/Pink Floyd - Wish You Were Here
01 - Shine On You Crazy Diamond (Parts I-V).m4a
02 - Welcome to the Machine.mp3
03 - Have a Cigar.mp3


/Pink Floyd
/Wish You Were Here
01 - Shine On You Crazy Diamond (Parts I-V).m4a
02 - Welcome to the Machine.mp3
03 - Have a Cigar.mp3

Thanks for your collaboration!


Hello haxcop,

Are you looking for advice on which method to use between the two you described ?
Either way, I don’t think it’ll matter much since Plex will get its metadata based on
filenames and embedded metadata (ID3 tags) to create its library.

Plex uses “Agents” (more info here) to scan your files and get metadata online
( seems to be their primary source).


The built in Plex agents that @Lotheric mentiones work pretty well. I believe Plex uses by as the default agent for metadata. I have noticed some inaccuracies with metadata provided by, so it’s not perfect, although it provides a great appearance and user experience.

If you are looking for more control and perfection in the metadata accuracy, you could apply metadata semi-manually. To do that, you can use MusicBrainz Picard to apply the metadata in bulk. Then you can disable the agent in Plex and just have Plex use only the embedded metadata in the media files.

As a bonus to using MusicBrainz Picard, it will also rename the files according to the Plex recommended file naming convention that you’re asking about. As you save the metadata, Picard will automatically rewrite the file names according to the string format you set… there are many options. In MusicBrainz Picard go to Options --> Options --> File Naming --> Name files like this --> and use a string. I use this string to get the results in the second option you asked about:

$if($ne(%albumartist%,),$num(%tracknumber%,2) - ,)%title%

/Pink Floyd
/Wish You Were Here
01 - Shine On You Crazy Diamond (Parts I-V).m4a
02 - Welcome to the Machine.mp3
03 - Have a Cigar.mp3

Hope that helps.


Hi @Lotheric & @michaelkruger Thanks for your prompt reply!. I have tested the plex without modifications but it’s not giving an accurate data as the majority of the songs. So i’ll try now the string that Michael suggest and check how it goes! I’ll update my answer soon¬! Thanks!


HI! I have added to the syntax
%artist%/%album%/$if($ne(%albumartist%,),$num(%tracknumber%,2) - ,)%title%

And this will organize between folders as I was looking to it before, but now i’m getting the symbol _ between artist names and it’s not the recommended options as it will be treated as one name.

I also would like to add the album year like:
Black Album - (1991) /
01 - Enter Sadman.mp3

Any suggestions? also the recommended options selected to avoid this kind of errors?.

Kind regards,


For the album year, I use


but you may prefer to use %date% instead of %originaldate%


Hi thanks for the tip but where exactly do you use it?. and how do you recomm to set the setting to avoid fill the spaces with the _ symbol.
Thanks in advance.


In your script,

would become


For the other questions, I did not answer because I have no idea, sorry. Actually, I don’t get underscores in place of spaces when I use Picard. Are you sure all spaces are replaced? Or only some special characters?


Hi I just want to say thanks for sharing such great code.

You’ve all helped answer most of my question without starting a new thread.

I hope it’s OK for me to revive this thread and ask a follow up question.

I am using this code - “$if($ne(%albumartist%,),$num(%tracknumber%,2) - ,)%title%”

but I would like to add artist to the end so that my track reads e.g. 10 - Truth - Bloc Party

Thanks for your help in advance :slight_smile:


Well, then just add the artist to the end :smiley: Adding “- %artist%” to the end of your existing code will do just that.



I have found this code,

$if2(%albumartist%,%artist%)/%album%/$num(%tracknumber%,2) -$if(%compilation%, %artist% -,) %title%

Is it possible to create a line of code that shows the various[quote=“outsidecontext, post:10, topic:17774”]

Hi Thanks,

Your reply was really helpful, just a follow up question. My code now looks like this

$if($ne(%albumartist%,),$num(%tracknumber%,2) - ,)%title%%artist%

I’d like to add a - between title and artist can I go ahead and change it so the last part looks like %title% - %artist% or do I need to modify it a different way?

Apologies if this is a dumb question and thank you for your help :slight_smile:


Yes, absolutely, I think you got it now how it works :smiley: Don’t be confused by all the functions with $(...). The basic for Tagger Script is really that it has some placeholders that get replaced by the proper value. So it’s like a template for the final name you want. E.g. this is how you would probably explain how you want the files being named:

“I want the file names to start with the track number, followed by the track’s title and the artist’s name, all parts separated by a dash.”

The tagger script for this will just be:

%tracknumber% - %title% - %artist%

Everything between two % signs is considered a variable, and that will be replaced by the specific value if this is applied to a specific file. Everything that is not a variable in the example above is just taken as is. So if you want to have “GEAT SONG” written to the end of each of your file names, just do it:

%tracknumber% - %title% - %artist% GREAT SONG

Now the script you actually have is a bit more complicated, it includes functions. A function can alter some value or give you the option to do things only, when a certain condition is met. So for example %tracknumber% by default will be just 1, 2, 3, 4 etc. But if you want to have leading zeroes, so you get 01, 02, 03, …, you can use the $num() function like so:


The number 2 here is the number of digits. Instead of 2 you could also use e.g. 3, resulting in 001, 002, 003,…

An example for a condition is that $if($ne(%albumartist%,),somevalue) expression. This will output “somvalue” only, $if the %albumartist% is set. $ne(%albumartist%,) means, test whether the albumartist variable is not euqal empty.


Thank you I understand much better now and really appreciate your help.

I wonder if you might help me and my next question over in this thread - How do I turn silver discs to gold discs?