Difference between revisions of "Foobar2000:Title Formatting Introduction"

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
(Fixed various misnomers, removed outdated/confusing information no longer relevant to current foobar2000 versions.)
m (Added sidebar template.)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
foobar2000 uses title formatting scripts in several places. This article will give you a basic introduction to title formatting patterns.
+
{{sidebar foobar2000 title formatting}}
 +
[[foobar2000]] uses '''title formatting''' scripts in several places. This article will give you a basic introduction to title formatting patterns. A full list of available title formatting commands is maintained at [[foobar2000:Title Formatting Reference|Title Formatting Reference]], and users can view examples from others and submit their own at [[foobar2000:Titleformat Examples|Titleformat Examples]].
  
== Just text ==
+
==Just text==
  
 
For example, you can customize the format of the playlist or the statusbar. The simplest thing you can do, is display some static text:
 
For example, you can customize the format of the playlist or the statusbar. The simplest thing you can do, is display some static text:
  
  This text will be displayed as-is.
+
This text will be displayed as-is.
  
Admittedly, this is pretty boring and you probably will not want to use this on its on. There is one more thing worth noting before we move on to more interesting things. Title formatting code uses some special characters which cannot be used in plain text, but you can use them inside single quotes:
+
Admittedly, this is pretty boring and you probably will not want to use this on its own. There is one more thing worth noting before we move on to more interesting things. Title formatting code uses some special characters which cannot be used in plain text, but you can use them inside single quotes:
  
  'These characters normally have special meaning: ( ) , [ ] $ %'
+
'These characters normally have special meaning: ( ) , [ ] $ %'
  
 
Single quotes, percent signs and ampersand can be included in the output, by doubling them outside single quotes.
 
Single quotes, percent signs and ampersand can be included in the output, by doubling them outside single quotes.
Line 15: Line 16:
 
Note that linebreaks will not appear in the output, unless they occur within single quotes:
 
Note that linebreaks will not appear in the output, unless they occur within single quotes:
  
  This is the
+
This is the
  first line.
+
first line.
  'This will stretch
+
'This will stretch
  to the second line.'
+
to the second line.'
  
 
Note that multiline scripts cannot be used everywhere; in the default components, they can be used for the text on the icon in the system notification area ("systray") and in the copy command script. The playlist and other singleline displays will truncate strings with line breaks, and would display the above example like this:
 
Note that multiline scripts cannot be used everywhere; in the default components, they can be used for the text on the icon in the system notification area ("systray") and in the copy command script. The playlist and other singleline displays will truncate strings with line breaks, and would display the above example like this:
  
  This is the first line. This will stretch (...)
+
This is the first line. This will stretch (...)
  
Comments are achieved by placing '//' at the start of a new line of code.  That entire line will be commented out, eg.
+
Comments are achieved by placing {{code|//}} at the start of a new line of code.  That entire line will be commented out, e.g.
  //This is commented and will not appear// this is also commented due to the '//' at the start of the line
+
  This is not commented and will appear// this and the '//' preceding it will also appear, because there is no '//' at the start of the line
+
  
== Song information ==
+
//This is commented and will not appear// this is also commented due to the '//' at the start of the line
 +
This is not commented and will appear// this and the '//' preceding it will also appear, because there is no '//' at the start of the line
 +
 
 +
==Song information==
  
 
Title formatting scripts would be quite useless, if you could not display information about songs. To access the value of the "title" tag, you would write "title" in percent signs:
 
Title formatting scripts would be quite useless, if you could not display information about songs. To access the value of the "title" tag, you would write "title" in percent signs:
  
  %title%
+
%title%
  
Actually, the above is a little smarter than just using looking at the "title" tag. If the title tag is missing, it will use the filename instead. There are several of this field remappings that are intended to make your life a little easier; among them are <code>%artist%</code>, <code>%tracknumber%</code>, <code>%list_index%</code> and of course <code>%title%</code>.
+
Actually, the above is a little smarter than just using: looking at the "title" tag. If the title tag is missing, it will use the filename instead. There are several of this field remappings that are intended to make your life a little easier; among them are {{code|%artist%}}, {{code|%tracknumber%}}, {{code|%list_index%}} and of course {{code|%title%}}.
  
 
A name written inside percent signs will generally try to look up the tag of the same name, unless it is one of the aforementioned remapped fields. Even in this case you can use the unaltered value of the tag:
 
A name written inside percent signs will generally try to look up the tag of the same name, unless it is one of the aforementioned remapped fields. Even in this case you can use the unaltered value of the tag:
  
  $meta(title)
+
$meta(title)
 
+
 
+
== Technical information ==
+
 
+
Technical information can be accessed in similar way as tags, either using <code>%__name%</code> or <code>$info(name)</code> where the name is one of those that can be seen in the "Other info" part of the properties window in foobar2000. There are some field remappings for technical information as well, for example <code>%bitrate%</code> gives you the average bitrate of a song or the current dynamic bitrate, if the song is playing, provided that the format supports reporting the dynamic bitrate.
+
 
+
  
==Additional Reading==
+
==Technical information==
  
* [[foobar2000:Titleformat Reference|Title Formatting Reference page]]
+
Technical information can be accessed in similar way as tags, either using {{code|%__name%}} or {{code|$info(name)}} where the name is one of those that can be seen in the "Other info" part of the properties window in foobar2000. There are some field remappings for technical information as well, for example {{code|%bitrate%}} gives you the average bitrate of a song or the current dynamic bitrate, if the song is playing, provided that the format supports reporting the dynamic bitrate.
  
[[Category:foobar2000 Guides|Titleformat Introduction]]
+
==See also==
 +
* [[foobar2000:Title Formatting Reference|Title Formatting Reference]]
 +
* [[foobar2000:Titleformat Examples|Titleformat Examples]]

Latest revision as of 21:00, 12 June 2022

foobar2000 uses title formatting scripts in several places. This article will give you a basic introduction to title formatting patterns. A full list of available title formatting commands is maintained at Title Formatting Reference, and users can view examples from others and submit their own at Titleformat Examples.

Just text

For example, you can customize the format of the playlist or the statusbar. The simplest thing you can do, is display some static text:

This text will be displayed as-is.

Admittedly, this is pretty boring and you probably will not want to use this on its own. There is one more thing worth noting before we move on to more interesting things. Title formatting code uses some special characters which cannot be used in plain text, but you can use them inside single quotes:

'These characters normally have special meaning: ( ) , [ ] $ %'

Single quotes, percent signs and ampersand can be included in the output, by doubling them outside single quotes.

Note that linebreaks will not appear in the output, unless they occur within single quotes:

This is the
first line.
'This will stretch
to the second line.'

Note that multiline scripts cannot be used everywhere; in the default components, they can be used for the text on the icon in the system notification area ("systray") and in the copy command script. The playlist and other singleline displays will truncate strings with line breaks, and would display the above example like this:

This is the first line. This will stretch (...)

Comments are achieved by placing // at the start of a new line of code. That entire line will be commented out, e.g.

//This is commented and will not appear// this is also commented due to the '//' at the start of the line
This is not commented and will appear// this and the '//' preceding it will also appear, because there is no '//' at the start of the line

Song information

Title formatting scripts would be quite useless, if you could not display information about songs. To access the value of the "title" tag, you would write "title" in percent signs:

%title%

Actually, the above is a little smarter than just using: looking at the "title" tag. If the title tag is missing, it will use the filename instead. There are several of this field remappings that are intended to make your life a little easier; among them are %artist%, %tracknumber%, %list_index% and of course %title%.

A name written inside percent signs will generally try to look up the tag of the same name, unless it is one of the aforementioned remapped fields. Even in this case you can use the unaltered value of the tag:

$meta(title)

Technical information

Technical information can be accessed in similar way as tags, either using %__name% or $info(name) where the name is one of those that can be seen in the "Other info" part of the properties window in foobar2000. There are some field remappings for technical information as well, for example %bitrate% gives you the average bitrate of a song or the current dynamic bitrate, if the song is playing, provided that the format supports reporting the dynamic bitrate.

See also