Add Track Number to Title Field

Hello. I am trying to add the track number and some characters before and after the track number added to the Title field string:

From: 003 Aria Hier ist das . . .

To this (the "01" is the track number):
003-01 Aria Hier ist das . . .

Then I need to add characters to this:
From: 003-01 Aria Hier ist das . . .

Bach: 003 [Ril] 01 Aria {Hier ist das...}

Is there any way to do this with a regular expression or several?


$replace($regexp(%TITLE%,'^(\d+) (.+)$','$1-{{1}} $2'),'{{1}}',%TRACK%)
003 Aria Hier ist das
003-01 Aria Hier ist das

Where do all the values come from?
???: 003
???: Ril
???: Aria
???: Hier ist das...
Are these values stored already in tag fields?
If so you can compose your TITLE string from the values out of the other tag fields.
Otherwise it would be a bit more difficult to create your format.

The string "Bach: " has to be prepended. Easy.
The string " [Ril] " has to be inserted by replacing "-" within the numbers "003-01". Easy.
Because the word "Aria" has to be encountered as an one word exception there is an unknown series of words from the tail which have to be enclosed with curly brackets. Problematic.


Thank you for your quick reply.

All of the information is in the title field (the same as filename), so some ideal end format examples would be:

Bach: 048 [Ril] 01 Coro {Ich elender Mensch, wer wird mich erlosen}
Bach: 048 [Ril] 02 Recitativo (A) {O Schmerz, o Elend, so mich trifft}
Bach: 048 [Ril] 03 Choral {Solls ja so sein, dass Straf und Pein}
Bach: 048 [Ril] 04 Aria (A) {Ach lege das Sodom der sundlichen Glieder}

But there are about 80 discs that I ripped and CDDB fills in the titles in various ways, such as:

22 BWV 187; Aria (S)_ Gott versorget alles Leben
01 Tˆnet, ihr Pauken! Erschallet, Trompeten! BWV 214 No. 1 Coro - Tˆnet, ihr Pau...
15 Bach_ 212 [Ril] 3 Recitativo (S_B)_ Nu, Mieke, gib dein Guschel immer her

Its a complete mess. So I wrote some replace and add and subtract actions to get it to a more manageable file name/title format. But I realize that automation will be out of the question.

How would I change the title field back - getting rid of the track name:

003-01 Aria Hier ist das
003 Aria Hier ist das

(I am really trying to learn regular expression)

$regexp(%TITLE%,'^(\d+)(?:-\d+)( .+)$','$1$2')
003-01 Aria Hier ist das
003 Aria Hier ist das