Store multiple album interpreters in a meaningful way

I have a problem with the two tag and file scripts:

$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
    $noop( Do nothing on a match. ),
    $noop( No match.  Do renaming. )
        $set(albumartist,$getmulti(%_albumartists%,0))
        $set(albumartistsort,$swapprefix(%albumartist%))
)
%albumartist%/
%album%/
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
		%artist% - %title%,
			%albumartist% - %title%
)

In the process, AC-DC would be renamed AC_DC. I do not see why.

there is one more point that happens when I enable “move files on save”.

From my folders:

  • Who
  • Beatles
  • Fantastischen Vier

then becomes:

  • The Who
  • The Beatles
  • Die Fantastischen Vier

I named them in the file system because it simplifies the search in the FS.

I have searched here in the forum. My first problem: AC/DC → AC_DC can possibly be solved with %_dirname%.

I guess this does not go into the tag script but into the one for file naming?

With $rreplace() you can exchange characters. Shouldn’t this work with that?

I also read a post that you can’t intervene on the characters “/” and "" at all.

You could wrap the %albumartist% tag that creates the folder with $swapprefix, e.g. $swapprefix(%albumartist%,A,An,The,Die).

Not in file naming scripts, because those are directory separators and if they would end up in the file naming script they would create folders. You don’t want that for AC/DC.

But you can define the replacement character used for directory separators (/ and \) in Options > Compatibility > “Replace directory separators with” (available since Picard 2.9). See File Naming Compatibility Options.

1 Like

ok, I have not seen this small field :frowning: That works quite simply :slight_smile:

So this goes into the file naming script? I tried it this way:

$swapprefix(%albumartist%,A,An,The,Die)/
%album%/
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
		%artist% - %title%,
			%albumartist% - %title%
)

But do not remove the preceding “The” from the directory:

No, it moves the prefixes to the end. But if you want to have them completely removed you can use the $delprefix function instead. It otherwise works the same, with the same parameters:

$delprefix(%albumartist%,A,An,The,Die)/
%album%/
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
		%artist% - %title%,
			%albumartist% - %title%
)
1 Like

It looks good like this. Thank you very much!

I will load different folders in Picard and hope that everything fits now.

1 Like

I’m assuming that you mean in the file naming. My guess is that the hyphen in AC-DC is actually a different unicode character (like en-dash) and it is being replaced with an underscore for compatibility reasons (depending on your configuration settings in this regard). To make sure that they are converted to ASCII hyphens, you could start your file naming script with something like:

$setmulti(_alt_hyphens,\u002D; \u058A; \u05BE; \u1806; \u2010; \u2011; \u2012; \u2013; \u2014; \u2015; \uFE58; \uFE63; \uFF0D)
$foreach(%_alt_hyphens%,
  $set(artist,$replace(%artist%,%_loop_value%,-))
  $set(artistsort,$replace(%artistsort%,%_loop_value%,-))
  $set(albumartist,$replace(%albumartist%,%_loop_value%,-))
  $set(albumartistsort,$replace(%albumartistsort%,%_loop_value%,-))
  $set(title,$replace(%title%,%_loop_value%,-))
)

Note that you could probably avoid the loop by using $rreplace() and building the pattern string to include the different alternate hyphen codes, but I thought this would be easier to follow.

These are my settings:

So I have not activated any conversion to ASCI.

Is it advisable to insert this anyway? This goes in the part “file naming” ?

With the current state with the $delprefix(%albumartist%,A,An,The,Die) at the beginning I found a case that is strange. After the directory of the artist “B.V.S.M.P” a _ is inserted:

That’s the trailing dot. Windows does not allow file or folder names to end with a dot, and Picard replaces this with an underscore. This is currently not directly customizable. One way to handle this in the script would be to just remove all trailing dots from this folder name. Replacing the first line of your script with this should do the trick (untested):

$rreplace($delprefix(%albumartist%,A,An,The,Die),\\.+\$,)/

The \\.+$ is a regular expression. “$” indicates the end of the string. \. is a single dot (needs escaping, as a dot is a special character in regular expressions), and the + indicates one or many of the character before.

So “R.E.M.” will become “R.E.M” without the last dot.

1 Like

I have inserted it like this

$rreplace($delprefix(%albumartist%,A,An,The,Die),\\.+$,)/
%album%/
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
		%artist% - %title%,
			%albumartist% - %title%
)

This leads to the message: "1:56: Unexpected character ‘,’.

Sorry, there was a missing backslash before the $ sign here. It needs to be \\.+\$ (because the dollar sign is special in Picard and indicates start of a function name).

I updated the script in my post above.

1 Like

Thank you, this correctly names “B.V.S.M.P”.

Does the file naming script use the variables, modified as they come from the tag script? The connection is not really clear to me yet.

Is there an easy way to remove the commas from the folder name (Albumartists)?

Essentially yes. Or rather the file naming script uses the variables and tags exactly as they are for a file when you hit “save”. So usually these get set by scripts and plugins, or in case of the editable tags by manual change.

Do you generally want to remove all commas from the folder name? Shall they stay in the file name?

For just removing all commas from the folder name use another $replace call:

$replace($rreplace($delprefix(%albumartist%,A,An,The,Die),\\.+\$,),\,,)/

It might be a bit hard to read with the many commas :slight_smile: $replace takes 3 parameters, the text to search in, the text that should be replaced and the text that it should be replaced with. So $replace(ABC,B,X) will replace the B with X in the input “ABC”, so it gives you “AXB”.

Now in our case we want to replace the comma with nothing, e.g. if %albumartist% is “A, B” then return “A B”. The comma is special and separates parameter, so we have to escape it:

$replace(%albumartist%,\,,)
2 Likes

This is how it looks gu. Yes, the main folder (albumartis) should be as simple as possible and never contain commas.

Thanks for the explanation! I test it :slight_smile:

1 Like

I’m trying to understand this. For better understanding I will remove the $delprefix:

$replace($rreplace(%albumartist%,\\.+\$,),\,,)

For me it is not clear by the commas what is B and what is X here, related to your explanation.

Could you split me from your syntax what is “B” and what is “X”? Then I hope I understand it.

I tried another simple example. If I want to replace all “_” in %album% with a space I thought the syntax would be:

$replace(%album%,\\_,)

But I guess that’s not true.

$replace(ABC,B,X)

For

$replace($rreplace(%albumartist%,\\.+\$,),\,,)

It would be

  • ABC: $rreplace(%albumartist%,\\.+\$,)
  • B: \,
  • X: nothing, the empty string between the last , and the final )

It would be

$replace(%album%,_,)

Your example would have replaced \_

$replace($rreplace($delprefix(%albumartist%,A,An,The,Tha,Die),\\.+\$,),\,,)/
$replace(%album%,_,)/
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
		%artist% - %title%,
			%albumartist% - %title%
)