MusicBrainz Picard/Documentation/Scripting
From MusicBrainz Wiki
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
- TODO: Add all tag names from UnifiedTagging here.
Functions
$if(if,then,else)
- If
if
is not empty, it returnsthen
, otherwise it returnselse
.
$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 fromtext
.
$right(text,num)
- Returns last
num
characters fromtext
.
$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, ,_))