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


redwing

  • Guest
How to Populate "Filename Only" Field

Currently <Filename> field returns filename plus file extension. Here's how to populate filename only with virtual tags.

Filename only = $Replace(<Filename>,.<.Ext>,)

redwing

  • Guest
How to Remove Last Backslash of <path>

  $Replace(<Path>*,\*,)

However, it's expandable to a more general formula, let's say you'd like to remove the last 5 characters of any field. First you have to choose a character (or a combination of more than one) that will never be part of that field in the same order, in the following example I use "qqq" instead of the "*":
   $Replace(<Anyfield>qqq,$Right(<Anyfield>,5)qqq,)

Deping

  • Guest

psychoadept

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 10691
Using <Random #> returns "Unknown Random #" ?

This is a known bug.  Search in the Bug Reports forum to comment on it.
MusicBee Wiki
Use & improve MusicBee's documentation!

Latest beta patch (3.5)
(Unzip and overwrite existing program files)

redwing

  • Guest
How to Identify Duplicate Filenames in an Auto-organized Library

When you have your library auto-organized, what happens if some files in the same folder get exactly the same filename according to your naming template? In that case MB appends underscore plus counter to the filename to distinguish each file from others. e.g.: "1-08 Right as Rain_1.mp3"
Thus you might, once in a while, want to check if there are any duplicate filenames in your auto-organized library. After identifying those, you could edit your template or delete duplicate files depending on the situation.

Duplicate Filename = $If($Left($Right(<Filename>,6),1)="_",Y,)

Duplicate Filename = $If($Left($Right($Replace(<Filename>,.<.Ext>,),2),1)="_",Y,)

will assign "Y" value to the files in filename ending underscore plus a single digit number.
Last Edit: February 26, 2014, 02:30:21 PM by redwing

psychoadept

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 10691
That's a good idea!  You'd have to do 7 digits for FLAC files, though.
MusicBee Wiki
Use & improve MusicBee's documentation!

Latest beta patch (3.5)
(Unzip and overwrite existing program files)

redwing

  • Guest
Good point! I edited the formula above to make it working with any kind of file extension. Thanks for reporting!

callimi

  • 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 = $Replace(<Path>,$Left(<Path>,9),)

This would return "Adele\..." value for each track. So replace the number 9 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, track 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.  

How to Create a "real" Virtual <Folder> tag

stating from your idea, i managed to create a virtual tag that give me the name of folder where my music file is located (wherever the file is, up to 8 levels)
That mean, If you have a music file located in  E:\Music\Goodmusic\ToShare\Arstist -Album\Mytitle.mp3
this tag will give you "Arstist -Album"
 
For doing so i create  8 virtual tags  and call the last one (I.e. Virtual9) : 

Virtual2 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,1),<Chemin>)
Virtual3 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,2),<Chemin>)
Virtual4 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,3),<Chemin>)
Virtual5 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,4'),<Chemin>)
Virtual6 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,5),<Chemin>)
Virtual7 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,6),<Chemin>)
Virtual8 = $If($Contains(<Chemin>,\),$Split(<Chemin>,\,7),<Chemin>)
Virtual9 = $IsNull(<Virtual8>,$IsNull(<Virtual7>,$IsNull(<Virtual6>,$IsNull(<Virtual5>,$IsNull(<Virtual4>,$IsNull(<Virtual3>,<Virtual2>,<Virtual3>),<Virtual4>),<Virtual5>),<Virtual6>),<Virtual7>),<Virtual8>)


Now you can add this "Real Folder" virtual field to library explorer, track browser, or main panel for easier browsing..


PS: do not hesitate to comment this post is you find a better way to do it !

redwing

  • Guest
How to Convert Date Format

If you want to convert date like "20110318" to "18/03/2011" format, use this:

Date Convert = $Date($Left(<Year>,4)/$Left($Right(<Year>,4),2)/$Right(<Year>,2),dd/MM/yyyy)

for changing to "03/18/2011" format, use this:

Date Convert = $Date($Left(<Year>,4)/$Left($Right(<Year>,4),2)/$Right(<Year>,2),MM/dd/yyyy)

Now you could copy the virtual tag values to date tag to convert the date format.

redwing

  • Guest
Easier Navigation with Artists on Thumbnail Browser

The biggest pain with using Thumbnail Browser is that it doesn't support AZ jump bar. Though you can type first letter and jump to those artists, it's not as convenient as it appears because you first have to select an item on Thumbnail Browser to take focus before typing. The better solution is to use a custom AZ jump bar with vertical Column Browser as posted before:

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))

Note: you can replace <Artist> with <Album Artist> or any other field in accordance with your tagging scheme.

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.

The same virtual tag can be used to easily navigate through a long list of artists in Thumbnail Browser.

AZ = $Group($Sort(<Artist>),1)

If using a first letter of artist like A, B, C... still lists too many artists, you can divide each letter into two groups like Aa, Ao, Ba, Bo,...

AaZo = $Group($Sort(<Artist>),1)$If($IsMatch($Right($Left($Sort(<Artist>),2),1),[a-n])="T",a,o)

will return "Ea" for Elton John and "Eo" for Eric Clapton.





Let's try one more step. For some letters where only a few artists are listed, you might not want divide them into two groups because if the AZ bar is too long then you have to scroll it up and down as well.

Custom AaZo = $Group($Sort(<Artist>),1)$If($IsMatch($Group($Sort(<Artist>),1),[gioqu-z])="T",,$If($IsMatch($Right($Left($Sort(<Artist>),2),1),[a-n])="T",a,o))

will not divide into two groups for first letters specified in [gioqu-z] part, which means "g", "i", "o", "q", "u", "v", "w", "x", "y", and "z".
Last Edit: March 23, 2014, 04:27:17 PM by redwing

redwing

  • Guest
How to Extract All <Featuring Artist> from Title

The following virtual tag returns all featuring artists specified in title.

Code
$RxReplace($RSplit($Split(<Title>,feat.,2),")",2),",|\s&",";")

Song Title
=> returns nothing

Song Title (feat. BBB)
=> BBB

Song Title (feat. BBB & CCC)
=> BBB; CCC

Song Title (feat. BBB, CCC & DDD)
=> BBB; CCC; DDD

Song Title (feat. BBB, CCC, DDD & EEE)
=> BBB; CCC; DDD; EEE

If you want, you can copy this virtual tag value to <Artists: Guest> field, using "Copy guest artists from <tag 1>" preset with Additional Tagging Tools plugin.
Last Edit: November 11, 2018, 02:57:46 PM by redwing

redwing

  • Guest
How to Convert "Composer" to <Last name, First name> format

This virtual tag converts composer name to "last name, first name" format as follows (thanks to the newly implemented $RSplit function, it's now much simpler with no word count limit):

Anonymous => Anonymous
Johaness Brahms => Brahms, Johaness
Ludwig van Beethoven => Beethoven, Ludwig van
Carl Maria von Weber => Weber, Carl Maria von

Sort-Composer = $IsNull(<Composer>,,$If($Contains(<Composer>," ")="F",<Composer>,$RSplit(<Composer>," ",1)", "$Replace(<Composer>*,$RSplit(<Composer>," ",1)*,)))

Note: You could also use ASR preset for the same purpose.

redwing

  • Guest
How to Identify Artists with Multiple Albums in the Same Year

I'm trying to do a search of artists that released multiple albums in the same year, and exclude everything else. How would one do that?

The quote above came from quite an old post (with no responses), but I've been wresting with the same issue for some time partly to enhance my file organization template. Anyway, I came to the conclusion that this kind of task can't be done without having "Album Count" field implemented.
Within the current functionality, the best solution I could think of is:

- Create a virtual tag "Multi-album" = $IsNull(<Year (yyyy)>,,$Sort(<Album Artist>)-<Year (yyyy)>)
- Add the field to library explorer category
- Set "sort by" option of the category to "Album"
- Tick "Show Count" option
- Now browse the field list and try to find items with a number greater than 1.



If there was "Album Count" field available, you could have a neat auto-playlist of only those tracks without having to browse all album artists.
Last Edit: September 09, 2014, 05:54:45 AM by redwing

redwing

  • Guest
How to Group Auto-calculated Album Rating

If you have the option "auto-calculate album rating" ticked under Preference> Tags (1), MB auto-calculates <Album Rating> as an average of track rating in the album. To display the number(0-100), you need to create a virtual field and add it to the main panel.

Album Score = <Album Rating>

You can also group the album rating using another virtual tag:

1. Go to Preferences> Layout (1)> Configure Fields
2. Find the virtual tag you created for album rating ("Album Score" in this case) and change its data type from "String" to "Number"
3. Define another virtual field "Album Range" using the following formula (note that this formula should use your own virtual tag label, "Album Score" in this case):

$If(<Album Score>=-1,"No Rating",$If(<Album Score>>10,$If(<Album Score>>20,$If(<Album Score>>30,$If(<Album Score>>40,$If(<Album Score>>50,$If(<Album Score>>60,$If(<Album Score>>70,$If(<Album Score>>80,$If(<Album Score>>90,91-100,81-90),71-80),61-70),51-60),41-50),31-40),21-30),11-20),0-10))

4. Add "Album Range" to column browser for grouping album rating.