Scripting

Scripts are used to control some aspects of the operation of Picard.

There are two types of scripts used in Picard: the file naming script and tagging scripts. These are managed from the “File Naming” and “Scripting” sections of the “Options ‣ Options…” menu.

Scripts are often discussed in the MetaBrainz Community Forum, and there is a thread specific to file naming and script snippets.

See also

Please refer to the section on Scripts in Extending Picard for additional details about the two types of scripts, including how and when each of the scripts are executed.

Syntax

The syntax is derived from Foobar2000’s titleformat. There are three base elements: text, variable and function. Variables consist of alphanumeric characters enclosed in percent signs (e.g.: %artist%). Functions start with a dollar sign and end with an argument list enclosed in parentheses (e.g.: $lower(...)).

Note

When entering input strings into Picard scripts you have to escape a backslash “\”, dollar sign “$”, comma “,” and the left and right parentheses “(” and “)” in order to force Picard to not interpret them as part of the script command. This is done by inserting a backslash before the character to be escaped. For example, to set a tag value to ($1,000,000) it would have to be entered as $set(test_tag,\(\$1\,000\,000\)).

Metadata Variables

See Tags & Variables for the list of the variables provided by Picard.

Picard’s variables can be either simple variables containing a single text string, or multi-value variables containing multiple text strings. In scripts, multi-value variables are automatically converted to a single text string by joining the values with a semicolon “;”, except when used with special multi-value functions.

Scripting Functions

The full list of available scripting functions is available, either sorted alphabetically or grouped by function type.