Skip to content

Code Examples

Justin Kruger edited this page Jun 6, 2020 · 4 revisions

Code Examples Intro

To make code examples easier to read, examples will be provided in an expanded syntax, that needs to have the spaces, and line return characters removed. In most code editors you can do this with a simple find and replace command (ctrl+R) or (cmnd+R).

Regular Expression Pattern

Matches 4 Spaces, or page return, or new line

(    |\r|\n)

Move "The" to the end of the artist name

"The Beatles" to "Beatles, The"

It's sometimes useful to sort band names by the 2nd word, skipping a common word or article like The.

Code Example

[IFVALUE]
    album artist,
    [IFEQUALS]
        album artist,
        The[DEL]1,4,[album artist][],
        [TRIM][DEL]1,4,[album artist][], The[]
    [],
    [IFEQUALS]
        artist,
        The[DEL]1,4,[artist][],
        [TRIM][DEL]1,4,[artist][], The[]
    []
[]
Copy & Paste
[IFVALUE]album artist,[IFEQUALS]album artist,The [DEL]1,4,[album artist][],[TRIM][DEL]1,4,[album artist][], The[][],[IFEQUALS]artist,The [DEL]1,4,[artist][],[TRIM][DEL]1,4,[artist][], The[][][][]

Add Disc Number, if there is one

Code Example

[IFVALUE]disc,[disc]-,[][track]

Trim a year(date) field to just the year

Depending on your configuration, the year field is sometimes rendered as yyyy mm dd. So, if you want to guarantee that you only have the year value you can use the below code snippet.

Code Example

[GRAB]1,4,[year][]

Uppercase the first letter of an Artist, Band or Album

Code Example

[UPPER][GRAB]1,1,[artist][][][LOWER][GRAB]2,,[artist][][]

Make a Folder of the first letter of an Artist

A\Aerosmith
M\Madonna

Code Example

[GRAB]1,1,[artist][]\[artist]

Pad Disc Number or Track Number

To zero pad a disc or track number to (2) places, use ASCII Char #48 for 0

01

Code Example

[SETLEN]2,48,,[disc][]

Decade Folders ( ie. 1980's )

To make a decades folder, and hash albums from years like 1995, 1984, 2007 into respectively 1990's, 1980's, and 2000's

Code Example

[SETLEN]3,32,32,[year][]0's

Unique Unknown Artist

To get a unique Artist folder for missing metadata; first configure dBpoweramp to insert Unknown Artist. Then, you can catch Unknown Artist and insert it's unique cddb_id. This will generate string as a unique artist for that disc.

This can also be used to create a unique album ID for either an unknown artist, or unknown album title.

Code Example

[IFEQUALS]artist,Unknown Artist,Unknown Artist ([cddb_id)[]