MusicBrainz Picard/Documentation/Scripting

From MusicBrainz Wiki
< MusicBrainz Picard‎ | Documentation
Revision as of 13:41, 8 October 2006 by LukasLalinsky (talk | contribs) ((Imported from MoinMoin))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Scripting in Picard

This section describes a simple scripting language implemented in PicardQt.

Syntax

The syntax is derived from Foobar2000's titleformat. There are three base elements: text, variable and function. Variables consist of alpha-numeric 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(...)).

Variables

Functions

$if(if,then,else)

  • If if is not empty, it returns then, otherwise it returns else.

$if2(a1,a2,a3,...)

  • Returns first non empty argument.

$lower(text)

  • Returns text in lower case.

$upper(text)

  • Returns text in upper case.

$left(text,num)

  • Returns first num characters from text.

$right(text,num)

  • Returns last num characters from text.

$num(num,len)

  • ..

$replace(text,search,replace)

  • ..

$search(text)

  • ..
  • TODO: add more functions, add descriptions

Examples

Use case 1: Disc numbers

$set(album,$replace(%album%,\(disc \d+(: [^)]+)\),))
$set(discnumber,$search(%album%,\(disc (\d+)\)))

Use case 2: Artist names

$if($search(%album%,(feat. conductor)),
  $set(artist,%orchestra%))
  • Stupid assumption that all classical albums have "feat. conductor" in the title, but it shows the idea. :)

Use case 3: Live tracks on live albums

$if($and($eq(%albumstatus%,live),$not($search(%title,(\(live\))))),$set(title,%title% (live)))

Lower case filenames with underscores

$lower($replace(%albumartist%/%album%/$num(%tracknumber%,2) %title, ,_))