Foobar2000:Titleformat Examples

From Hydrogenaudio Knowledgebase
Revision as of 11:32, 29 July 2007 by Mix de Rax (Talk | contribs)

Jump to: navigation, search
Foobar2000_Logo.png

Examples of general title format usage. Can be useful in Masstager or other components

Please make sure you rejoin scripts that have been split into multiple lines, before pasting them into the masstagger window. The reason they are split is to keep this page's formatting readable in your browser.


Returns corresponding tag field:

%tag%

Example: if artist field is blah %artist% will return blah. Note that you can insert any character (or space) in between two tags, in front or after, so if artist is blah and title is bleh

%artist%X%title%

returns blahXbleh.


Trunctuates %tag% to a length of X characters:

$cut(%tag%,X)

Example: if artist field is blah $cut(%artist%,3) returns bla


Truncuates %tag% by X characters and adds ... at the end of the cut.

$cut(%tag%,X)...

Example: if artist field is blah $cut(%artist%,3)... returns bla...


Returns numerical value of %tag% and pads with 0s up to x characters

$num(%tag%,X)

Example: if tracknumber field is 3 $num(%tracknumber%,2) will return 03. If 13 it will return 13.


Returns first two characters of a filename and displays as number (if present) padded with 0s up to X characters:

$num($left(%_filename%),2)

Example: if filename is 03_artist_title.mpc will return 03.


Finds first occurence of character X in %tag% and returns everything in front of X:

$puts(spacer,$strchr(%tag%,X))
$trim($left(%tag%,$sub($get(spacer),1)))

Example: blah X bleh or blah X bleh X bluh returns blah (ie.: artist_album_title -----> title, in case X is _ )


NOTE:In the next few strings I have decided to make it possible to define the %tag% that should be edited and the character or string that is used to determine where to trunctuate as variables in the beginning of the string as $puts(tag,%tag%), $puts(char,X), etc. Basically the reason I have done this is to make it simpler to edit these strings, to what you exactly want them to do at the very moment, in the rather narrow masstager input field. That way it is possible to enter the needed tags and characters only once in the beginning of the line. Again simply replace %tag% and X by the desired values. Also all of these strings will trim off the trailing and leading spaces of the output (in case there are any).


Finds first occurence of character X in %tag% and returns everything in front of X:

$puts(char,X)$puts(tag,%tag%)$puts(spacer,$strchr($get(tag),$get(char)))
$trim($left($get(tag),$sub($get(spacer),1)))

Example: blah X bleh or blah X bleh X bluh returns blah (ie.: artist_album_title -----> title, in case X is _ )

Note: this does exactly the same as the last string mentioned above, except for the introdution of the two variables in the front, meant for easy editing


Finds last occurence of character X in %tag% and returns everything in front of X:

$puts(char,X)$puts(tag,%tag%)$puts(spacer,$strrchr($get(tag),$get(char)))
$trim($left($get(tag),$sub($get(spacer),1)))

Example: blah X bleh returns blah and blah X bleh X bluh returns blah X bleh


Finds first occurence of character X in %tag% field and returns everything after X:

$puts(char,X)$puts(tag,%tag%)$puts(spacer,$strchr($get(tag),$get(char)))
$trim($right($get(tag),
$sub($len($get(tag)),$get(spacer))))

Example: blah X bleh returns bleh and blah X bleh X bluh returns bleh X bluh


Finds last occurence of character X in %tag% field and returns everything after X:

$puts(char,X)$puts(tag,%tag%)$puts(spacer,$strrchr($get(tag),$get(char)))
$trim($right($get(tag),
$sub($len($get(tag)),$get(spacer))))

Example: blah X bleh returns bleh and blah X bleh X bluh returns bluh


Finds first occurence of character X and last occurence of character Y and returns everything in between:

$puts(char1,X)$puts(char2,Y)$puts(tag,%tag%)
$puts(spacer1,$strchr($get(tag),$get(char1)))
$puts(spacer2,$strrchr($get(tag),$get(char2)))
$trim($substr($get(tag),$add($get(spacer1),1),$sub($get(spacer2),1)))

Example: blah X bleh Y bluh returns bleh

Note: that in most cases X will probably be equal to y here.


Finds first occurence of string XYZ and returns everything in front of string XYZ:

$puts(string,XYZ)$puts(tag,%tag%)$puts(spacer,$strstr($get(tag),
$get(string)))
$trim($left($get(tag),$sub($get(spacer),1)))

Example: blah XYZ bleh returns blah

Note: that string XYZ can basically be any combination of characters or words.


Finds first occurence of string XYZ in %tag% field and returns everything after XYZ:

$puts(string,XYZ)$puts(tag,%tag%)
$puts(spacer,$strstr($get(tag),$get(string)))
$trim($right($get(tag),$sub($len($get(tag)),
$add($get(spacer),$len($get(string))))))

Example: blah XYZ bleh returns bleh