Do you have experience writing complex functions for spreadsheets (functions involving if statements and such)?
The way MC does expressions is similar to spreadsheets. Expressions are all in one line of text, functions get nested within other functions, you can get several layers deep in parenthesis. It can be confusing trying to decipher.
The list and explanation of available functions is here:
Media Center expression languageThe general layout for an if statement is: If(TEST_EXPRESSION, WHAT_HAPPENS_WHEN_TRUE, WHAT_HAPPENS_WHEN_FALSE)
Here's an example of my directory naming rule:
[library]\[Album Artist (auto)] - [Album]If(IsEmpty([Disc #],1),,-PadNumber([Disc #],2)) [[File Type]]
Here's an example of my file naming rule:
Mid([Album Artist (auto)],0,20)-Mid([Album],0,20)-If(IsEmpty([Disc #],1),,PadNumber([Disc #],2))-PadNumber([track #],2)-Mid([Name],0,20)
Let's take an example from my directory naming rule
If(IsEmpty([Disc #],1),,-PadNumber([Disc #],2))
What it does.
If the [Disc #] field is empty it prints out nothing
If the [Disc #] field is not empty it prints out a dash "-" and the disc number padded to two digits
It is a bit confusing with the nested parenthesis. It is easier to follow if you use a text editor that is designed for programming text. The better editors will have a function that highlights matching braces and parenthesis.
Alternatively, you can edit the expression in a regular text editor and indent each level of parenthesis. Something like this:
If(
IsEmpty(
[Disc #],1
)
,
,-PadNumber(
[Disc #],2
)
)
That makes it easier to keep track of the parenthesis while creating and editing the expression. Then when you are done you edit it back to a single line of text and paste it in Media Center.