Script for all Audio Files

Hi,
yesterday i have found MusicBrainz for Tagging my Media Files and have seen that i can Scripting to make my own library. :blush:

Today i start my first script and hope that someone can help me for my questions.

At first i start to script Albums
Music/Interprets/A-Z/Interpret/Album (YYYY)/CDnr-TitleNumber. Titel
Music/Interprets/A/Anastacia/Not that Kind (2000)/1-01. Not that Kind.mp3

Now i want to include Compilations with a different path and want to ask how i can include it?
In Java i create an if statement, it is here possible to do it?

The Path for Compulations will be different and looks like
Musik/Compilations/Albuminterpret/Album (YYY)/CDnr-TitleNumber. Interpret - Title
Music/Compilations/Bravo Hits/Bravo Hits Vol 001 (1988)/1-01. Sandra - Dont´t be Agressive.mp3

There must define some parameters that must created
When it will be see an Bravo Hits as Compilation then it will set Albuminterpret as “Bravo Hits” Add “Vol” and make the Number “001” three characters.
In Java i have programmed it with al List of Compilations and when it is true then these Parameters wqill be calculated.
It is possible to do that here with scripting too?

Ho i can define an comment in the Script?

Thanks

My Script at this time.

Interpreten/
$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/
%albumartist%/
%album% ($if2(%date%,%originaldate%))/
%discnumber%-$num(%tracknumber%,2). %title%
1 Like

You could have a look here:

You will find a lot of useful working examples and ideas too.

https://picard-docs.musicbrainz.org/en/functions/func_noop.html

2 Likes

Thanks this helps.

I have seen in Preferences Scripts there can create more scripts.
It is better when i create a script only for Interpret-Album then an own script for Compilations?

Or it is better to create only one Script for all?
Interpret-Album, Compilations, Singles, Audio-Book, Radio Play, and so on.
Thanks

The script in Options > Scripting are for modifying the loaded metadata. There is only a single file naming script.

You can distinguish between compilation and other releases with something like this:

$if($eq(%compilation%,1),COMPILATION NAMING,ALBUM NAMING)

E.g. do:

$if($eq(%compilation%,1),
$noop(Various Artist albums)
Compilations/
%albumartist%/
%album% \($if2(%date%,%originaldate%)\)/
%discnumber%-$num(%tracknumber%,2). %artist% - %title%
,
$noop(Single Artist Albums)
Interpreten/
$upper($firstalphachar(%albumartistsort%))/
%albumartist%/
%album% \($if2(%date%,%originaldate%)\)/
%discnumber%-$num(%tracknumber%,2). %title%
)

You will also see this in the two examples below the script, the second example is for a compilation and will show accordingly

2 Likes

Hi,
I want to update the script.
Which Tag i must use to shown the script as above.

Thank you

Not sure what you mean, you mean showing the script here in the forum with syntax highlighting? For this look at the first comment at Repository for neat file name string patterns and tagger script snippets

1 Like

I want to show the script in the grey box with highlitet syntag as in your answer.
It must be a tag because formatted text will not do it.

Yes, as I said this is explained in the link I posted

I now understand how scripting will works. I hope so.

The actually script

$if($eq(%compilation%,1),
$noop( ####    Ablage für Zusammenstellungen    ####)
%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4))\)/
%discnumber%-$num(%tracknumber%,2). %artist%
,
$noop( ####    Ablage für Alben von Interpreten    ####)
Interpreten/
$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/
%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4))\)/
%discnumber%-$num(%tracknumber%,2). %title%
)

Will generated this


I dont know why it is so?

You can check the Example “preview” part in MusicBrainz Picard:

Just try to find the unnecessary “)” after the albumname and after the trackname.
For the second part, I suggest:

,
$noop( ####    Ablage für Alben von Interpreten    ####)
Interpreten/
$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/
%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title%
1 Like

I have test the script code separate and it will work without problems?

Your part A and B both still have an unwanted(?) closing ) after the year in the albumname:
Not That Kind (2000))
and
Bravo Hits 1 (1992))

I assume, there is still a ) too much in your code. Please compare carefully:

, 0000),4)\)/

Yes, the additional closing brackets are the issue. Tagger script actually is tolerant about closing brackets, if they are not needed because of an opening bracket they just get interpreted as the character. But I would not advise this, always escape opening and closing brackets you want to use as the character with \( and \).

Also your use of $firstalphachar should just be $firstalphachar(%albumartistsort%,#) or even $firstalphachar(%albumartistsort%). The second parameter is the character to use if the first character is not alphabetic. The default is #.

$if($eq(%compilation%,1),
$noop( ####    Ablage für Zusammenstellungen    ####)
%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %artist%
,
$noop( ####    Ablage für Alben von Interpreten    ####)
Interpreten/
$upper($firstalphachar(%albumartistsort%,#))/
%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title%
)
1 Like

Thanks for Answer,
i have found it too and removed it.
now the Script will run correctly and can expand it.
Thanks

2 Likes

i want to include one folder that will stack more of compulations of their series.
Bravo Hits Volume 1…x save to the folder “BravoHits” but it doestn work.
It is a problem in the if statement?

Thanks

$if($eq(%compilation%,1),
$noop(Ablage für Zusammenstellungen)

$if($in(%album%, Bravo Hits), $set(%albumartist%, Bravo Hits))

%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title% - %artist%
,
$noop(Ablage für Alben von Interpreten)
Interpreten/
$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/
%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title%
)

Try removing the spaces between the commas and “Bravo Hits”. You should also remove the space after the comma in %album% \($left($if2(%date%,%originaldate%, 0000),4)\)/.

1 Like

i have do it, but it doesn´t work?

I’m not completely sure that I understand how you want these albums to be saved, so the following may or may not do it for you. [I have not tested the following code.]

$if($in(%album%,Bravo Hits),$set(albumartist,Bravo Hits)$set(compilation,1))

$if($eq(%compilation%,1),
$noop(Ablage für Zusammenstellungen)

%albumartist%/
%album% \($left($if2(%date%,%originaldate%,0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title% - %artist%
,
$noop(Ablage für Alben von Interpreten)
Interpreten/
$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/
%albumartist%/
%album% \($left($if2(%date%,%originaldate%,0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title%
)

Part of the problem (perhaps the whole problem?) was that you were assigning the text “Bravo Hits” to a tag named by the contents of %albumartist% rather than a tag named albumartist. When you’re using $set() don’t use the percent signs around the name of the tag to set. This is a common mistake that we all have made at one time or another. In fact, I missed it when I provided my earlier response.

2 Likes

Thank you for the very importanto informations.
I will notice it in my working document.
There are not so many Compilations that need to stack it in own albumartist, the i can define it in the script as if and set statement.
Now the folder will work.
MusicBrainnzFiles
The acually script

$if($eq(%compilation%,1),
$noop(Ablage für Zusammenstellungen)
$if($in(%album%,Bravo Hits),$set(albumstack,Bravo Hits))

%albumartist%/
%albumstack%/
%album% \($left($if2(%date%,%originaldate%,0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title% - %artist%
,
$noop(Ablage für Alben von Interpreten)
Interpreten/
$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/
%albumartist%/
%album% \($left($if2(%date%,%originaldate%, 0000),4)\)/
%discnumber%-$num(%tracknumber%,2). %title%
)

Thanks

1 Like

Where do you set the folder “Zusammenstellungen” above your “80’s Love Songs”- and “Bravo Hits 1”-folder?