Expression Field Assignment is very powerful and useful for manipulating the values of your Fields and can do all kinds of clever things.
In a recent thread, I pointed out how =Counter() could be used to automatically "number" any field sequentially, just like the built-in
Fill Track Numbers from List Order tool. It dawned on me that many other folks may not be aware of this powerful feature introduced in the
Liberace Rubber Chicken Build in the long, long ago. And, more importantly, it would be cool to have a thread where we could share handy expressions to use for manipulating fields! So, come out your pockets!
For the uninitiated:
You can assign the value of any field to the "output" of an expression by prefixing the expression with an equals sign (=) in the field editing box (in the Tag Action Window or inline in a details view). This can be used to "modify and massage" the information included your fields in Media Center in almost any way you can imagine using the
Expression Language.
The simplest example is to copy information from one field to another as it is. Say you wanted to copy the value of [Album] over to the [Comment] field on a bunch of files for some reason. You can do this "inline" by:
1. Select a file or set of files.
2. Edit the [Comment] value in the Tag Action Window.
3. Type:
=[Album]That's cool, but of course the built in
Library Tools\Move / Copy Fields tool does this and has more options than just copying the existing value. But, the power is that you use any expression to manipulate the values first.
I provided another simple example in the other thread linked above. If you want to automatically "number"
any field, just like the built-in Library Tools\Fill Track Numbers from List Order tool does on [Track #] you can:
1. Select the set of files.
2. Edit the field you want to number in the Tag Action Window.
3. Type:
=Counter()When editing a field, you can even manipulate the current values of that field by simply referencing "itself" in Square Bracket Notation. So, if you have a bunch of files that have good [Name] values, but for some reason all have 7 random digits after them in the field (as in my original example requesting the feature) you can use:
=RemoveRight([Name],7)
Even when you are editing the [Name] field. It uses the value of the field from before the new expression is applied "to itself". However, see my first tip below...