Author Topic: Useful virtual tag formulas  (Read 75431 times)

redwing

  • Guest
I thought it would be useful if users share virtual tag formulas designed to perform a special task. Keep in mind though that long and complicated virtual tag formulas consume lots of system resources and slow down MB. So use them for one-time task only if you think they could give quite a system load. Feel free to add any virtual tag formulas to this thread if you think they could be useful to other users.

---------------
How to Create a Virtual Tag

1. Go to Edit> Preferences> Tags (1)> Define New Tags.
2. Enter a label and formula in one of the boxes in the lower half of the dialog.
3. Now you can add the field to main panel or use the field for "group by" or "sort by".
Last Edit: March 20, 2014, 04:44:07 PM by redwing

redwing

  • Guest
Custom AZ Bar Using Vertical Column Browser

AZ bar is useful but it responds only to sort column which feels sometimes cumbersome. To avoid this, you can create your own custom AZ bar using a virtual tag and vertical column browser. It also filters to the selection.

1. Create a virtual tag as follows:

(1) For general use: AZ = $Group($Sort(<Artist>),1)

(2) If you have classical music tracks and want them grouped by composer rather than by artist:
AZ = $If(<Genre>="Classical",$Group($Sort(<Composer>),1),$Group($Sort(<Artist>),1))

(3) If you want to group artists by their last name, then use this instead:
Last = $Group($RSplit($First(<Artist>)," ",1),1)

It populates the first letter of the last word in artist field value. And if multiple artists are tagged, it takes the first artist's last name.
Also you can replace <Artist> field with <Composer> if you want to group composers by last name.

2. Configure column browser in vertical layout with one column of "AZ" field. Enabling "Show track count" could be useful too.

3. When you want to return to full list after filtered to a subset , click on "all" at the top or the selected node in left navigator.

Last Edit: May 21, 2016, 04:42:55 PM by redwing

redwing

  • Guest
How to Sort Tracks by Title in "Letters-Numbers-Symbols" order

1. Create a virtual tag with the following formula.

Code
$If($IsMatch(<Title>,"^[a-zA-Z]")="T",1<Title>,$If($IsMatch(<Title>,"^[0-9]")="T",2<Title>,3<Title>))
2. You can either create a custom sorting set using that virtual tag and sort by that field or just add the virtual tag to the main panel and sort by it. Also you can create the same sorting virtual tags for <Artist> and <Album> if you just replace <Title> with those fields using the formula above.
3. To use "ignore words" option, replace "<field>" with "$Sort(<field>)". So for "<Title>", use "$Sort(<Title>)" instead.

Note: Originally posted here
Last Edit: July 26, 2017, 03:31:56 AM by redwing

frn_747

  • Guest
One question, redwing...
Your solution is very interesting but a screenshot could be nice to see how it looks afterwards:
2. Configure track browser in vertical layout with one column of "AZ" field. Enabling "Show track count" could be useful too.

Would you please?

redwing

  • Guest
One question, redwing...
Your solution is very interesting but a screenshot could be nice to see how it looks afterwards:
2. Configure track browser in vertical layout with one column of "AZ" field. Enabling "Show track count" could be useful too.

Would you please?

I did. Thanks for your interest.

redwing

  • Guest
How to Display <First Artist> only

This is a pretty simple one, but if you're not familiar to virtual tag functions it might not be apparent at first glance.
If you have lots of multiple artist tracks and do not use album artist field, then artist field won't look good due to the lengthy chained artist names. This could be a problem for grouping by the field or displaying it on player scroll.

Create a virtual field as follows:

FA = $Sort($First(<Artist>))

Now use the field as if it's album artist field.
Last Edit: April 26, 2013, 10:43:48 AM by redwing

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
Keep in mind though that long and complicated virtual tag formulas consume lots of system resources and slow down MB. So use them for one-time task only if you think they could give quite a system load.
to expand on this - if you are only displaying a virtual field then there is very little overhead. Its only when you use the virtual field for sorting, grouping (which includes the library explorer and track browser) or as filtering criteria that is potentially becomes more expensive if you have a lot of files

redwing

  • Guest
Keep in mind though that long and complicated virtual tag formulas consume lots of system resources and slow down MB. So use them for one-time task only if you think they could give quite a system load.
to expand on this - if you are only displaying a virtual field then there is very little overhead. Its only when you use the virtual field for sorting, grouping (which includes the library explorer and track browser) or as filtering criteria that is potentially becomes more expensive if you have a lot of files

Thanks for the clarification! That corresponds to my experience with complicated virtual tags.

redwing

  • Guest
How to Group Tracks by <Album Artist (Album)> format



Create a virtual field as follows (of course, you can edit the format as you like)
 
AA_Album = $Sort(<Album Artist>) (<Album>)

Then right click on column header, click Group by, and select "AA_Album" field under virtual field.
Last Edit: April 26, 2013, 10:44:51 AM by redwing

redwing

  • Guest
How to State "contain" and "does not contain" in Virtual Tags

[Added]

This post is now obsolete since new functions were added for this purpose.

i've added these search functions:
$Contains(<field>, search-text)
$IsMatch(<field>, regex-pattern)

[Original Post]

You can define a rule with "contain" or "does not contain" condition for auto-playlists.  You can do the same for a field with virtual tags, and use it for various purposes.

The key is to combine $If and $Replace function.
Let's say you want to display "Rock" in a virtual field if a track contains a word "rock" in <Genre> tag; if not, display "Pop".

Pop_or_Rock = $If($Replace(<Genre>,rock,)=<Genre>,"Pop","Rock")

This can be used independently like the example above, but could be more useful when used as a condition for another virtual tag (See next post).
Last Edit: October 30, 2013, 10:24:06 PM by redwing

redwing

  • Guest
How to Define <Ensemble> field for Classical Music Tracks

Because MB uses <Display Artist> field values for <Artist> field in main library and virtual tags, it's a good idea to keep a consistent format for Display Artist field to use it for various purposes.
I'm using a semicolon between multiple artists, so it is easy to display artist value in a specific position.
For most classical pieces, ensemble is placed in the second position in multiple artist field next to conductor.
Then the formula would be like this:

Ensemble = $Split(<Artist>,";",2)

But for concertos, ensemble is in the third artist, following soloist and conductor. I am using <Grouping> field for sub-genres for classical music which contains "Piano Concerto," "Violin Concerto", etc.
So the field should display third artist when <Grouping> filed contains "Concerto", otherwise second artist.

Ensemble = $If($Replace(<Grouping>,Concerto,)=<Grouping>,$Split(<Artist>,";",2),$Split(<Artist>,";",3))


Last Edit: April 26, 2013, 10:46:38 AM by redwing

redwing

  • Guest
How to Identify Files with Extremely Lengthy Path

First have a look at this post:

one of the recurring problems reported is long generated filenames based from tags that exceed the windows limits:
260 chars for total length, 247 for the directory path (I realise that windows can support longer filenames, but that API is not available from .NET and i dont think its well supported in windows)

what i propose to do is where a tag exceeds 70 chars in length, MB will use the first 64 chars and append a unique 6 char string
c:\music\01234567890123456789012345678901234567890123456789012345678901234567890123456789\file.mp3
becomes
c:\music\0123456789012345678901234567890123456789012345678901234567890123~B998CD\file.mp3

i appreciate you could still theoretically get a file that has say 4 large tags in the path\filename that exceed the limits.

If anyone has concerns about this approach let me know as i plan to include the change in the next update. It wont apply to existing files, only to files as they next get organised in MB eg. auto-organise is enabled and you edit a tag, files added to an auto-organised library, manual re-org etc

the file organiser now displays a warning.
Additionally i improved the algorithm so it only shortens the filenames when it absolutely has to

So MB helps the user to take care of the issue, but the best way would be you handle extremely lengthy tags first that are used in your file-naming template before such a problem arises. Hence the question is how to identify those tracks? There may be some other ways, but the recently implemented $IsMatch function would be probably the simplest one to use and modify.

Lengthy_Path = $If($IsMatch(<Path><Filename>,"^.{201,}$")="T",">200",)

This would return ">200" for any tracks with full path name (path + filename + file extension) exceeding 200 characters; otherwise null.

Also you can check whether the above-mentioned MB handling is already in action with any of your tracks by using the following virtual tag:

Lengthy_Tag = $If($Contains(<Path><Filename>,~)="T","Y",)

This would return "Y" for any tracks with its path containing "~"character; otherwise null.
Last Edit: October 15, 2013, 08:46:59 PM by redwing

redwing

  • Guest
How to Create a Virtual <Folder> tag

If you frequently access and play files from their folders, MB's Computer node in left navigator might not offer desirable functionality for navigating and quick-accessing different folders. Then you might want to use a virtual field starting with the folder name you'd like to populate.

If you have a folder structure starting with E:\Music\Adele,
 
Folder = $Split(<Path>,\,3)

This would return "Adele\..." value for each track. So replace the number 3 with any number depending on your folder structure.
If you have different folder structure according to genre, etc., you can modify the formula above using $If syntax.

Now you can add this "Folder" virtual field to library explorer, column browser, or main panel for easier browsing. The difference between this and using the tag (in this case "Artist" tag) is that this directs to the corresponding folder instead of a group of tracks corresponding to the tag value. 
Last Edit: July 28, 2016, 08:17:45 AM by redwing

blau

  • Guest
Hello redwing,

I would like to ask if is it possible to add a virtual tag to open an external file, for example a .txt file.
I'm a complete newbie at this, tho modifying your last How to Create a Virtual <Folder> tag to:
<Path>adele.txt  i get E:\Music\Adele\adele.txt but clicking (or double clicking) on it just do nothing (that I can see).

...Perhaps I'm over-complicating myself and there is another option I'm no aware of in MB that do the same

Any hint will be much appreciated
Thanks

redwing

  • Guest
Hello redwing,

I would like to ask if is it possible to add a virtual tag to open an external file, for example a .txt file.
I'm a complete newbie at this, tho modifying your last How to Create a Virtual <Folder> tag to:
<Path>adele.txt  i get E:\Music\Adele\adele.txt but clicking (or double clicking) on it just do nothing (that I can see).

...Perhaps I'm over-complicating myself and there is another option I'm no aware of in MB that do the same

Any hint will be much appreciated
Thanks

No, it doesn't mean the actual file. That means just displaying <Path> plus some words you typed in, and it will show the same thing for any file (each file's path plus the same filename you typed in). For one thing, MB can't display files other than file types playable with it. For another, virtual tag is sort of tag just like Title or Artist, so it can't be used for such purpose.