[Solved] Tagger Script for renaming files does not pickup on manually changed Artist name


I am using Bob Swift’s @rdswift really excellent file naming script. It also needs the Additional Artists Variables plugin.

It all works great - except when it comes to artists; namely, if I modify the artist manually in the pane for tags. The script will keep on using the old values. It is as if the plugin ran before, collected the values and the plugin does not get notified of the manual changes. At least that is my theory. I do not know how the plugin structure works in picard.

I am running Picard as a snap package in linux, ver 2.7.0b2.

The relevant parts of the script that I found retain the old values and not the new ones is here:


And specifically these variables, which I think are populated by the plugin:

%_artists_track_primary_cred%, %_artists_track_additional_cred% and %_artists_track_all_cred%

Obviously if Bob would answer he’d likely be the best one, But anyone who has some ideas about how to fix this would be great. I do not want to particularly mess with replacing the variables in Bob’s script because his script is well thought out and nilly willy replacing variables means I will then not cover all the various scenarios when it comes to artists and featuring artists, etc.

Thank you!

That is exactly the case. Unfortunately, I can’t think of a simple way to get around that right now. You might be able to include something in the script to check if the old and new artist names differ and then do a replace in the relevant variables. To do that, you likely need a tagging script to save the “before” values to a new variable so you have something to compare to the values proved to the naming script.

Darn that is very very unfortunate. From what I surmise, this is because Picard does not have a framework to notify the plugins of changed tags and allow the plugins to re-run, correct?

In that case, would it not have been better, in order to solve this frankly common scenario, to instead have the plugin it be another tagger script that collects all the artists into variables? That way, one could re-run this script, making the variables (is this possible?) later available to this other script.

Or, am I wrong, and there is no way to persist tagger script variables between various scripts, and that is why you wrote it as a plugin?

Thanks for the discussion

I wrote it as a plugin because it provides access to otherwise unavailable information. It simply couldn’t be done as a script alone.

Tags and variables that you define are stored in the metadata for each track, so they are available to other scripts that follow.

The metadata plugins run when the metadata is retrieved from MusicBrainz. There are other event hooks that can be used to trigger different plugins, and of course tagger scripts can be run manually at any time. For more information about the order in which things happen, have a look at the Processing Order section of the Picard User Guide. The Extending Picard page also points to sections specifically dealing with Scripts and Plugins.

Thank you Bob for all the explanations. Thank you also for your involvement with this project and for your naming script. It has been an excellent springboard for me.

I will now spend more time understanding what your plugin does. I am still confused about the actual usage of the three variables I mentioned in my original post that are set in your plugin. If perhaps you could explain those to me or point me to where I can read more about this, then I can roll up my sleeves and hammer out a solution along your suggestions.

Thank you kindly!

The variables provided by the plugin are documented on my GitHub repo. I’m not sure which three variables in particular you were asking about. If they are not in the list provided by the plugin, then they are simply local variables that I used in the script. If you let me know which ones you questioned, I can try to explain them further.

These ones:

Thank you

Those are all defined in the document at the github link I provided. If those definitions aren’t sufficient, what are your specific questions?

I read your github definitions of these variables.

I guess my specific question would be how these variables are set (meaning from where within picard they are obtained) and if these variables are truly only accessible within the plugins or if they can be accessible from within tagger scripts.

I am sorry; I am new to this so still trying to piece it all together. Thanks

The information for these variables is part of the metadata provided by MusicBrainz, but not all of it is made available for scripting by Picard. This plugin makes all of it available for scripting by creating the additional variables. All of these (new) variables can be used in any of your scripts (tagging or file naming). What you do with them is up to you. If you want to replace the content of some of the variables with the tag values (which you say you change) then that’s what you should do. Simply create a tagging script that sets the new values for the variables, and that way you don’t need to modify the file naming script at all. For example, you could do something like $set(_artists_track_primary_cred,%artist%) and then when you run this script manually by right-clicking a selected track and running from the context menu, it will then use your value for the file naming script. The difficult part will be finding the appropriate tag to use for the replacement value.

Thank you Bob, it is starting to become clear. I played around with it today and was doing precisely what you suggested. And indeed, the difficult part is to figure out if I change let’s say artists tag in the pane for a file, how would it for example affect variable _artists_track_primary_cred ?

So that is where I am now.

Thanks for the discourse; it has been helpful and hopefully it helps others as well. Cheers

Ok so after pouring over the plugin code, I cannot very well figure it out. That is because some of the variables come from picard via lists using indices, so it makes it very hard to understand where those variables really come from, and more importantly, their relationship to actually exposed tags in the pane like artist, album artist, artists, etc.

So because I cannot see the correlation, it is very hard for me to see what variables I should set to what value in a tagger script so that the file naming script can pickup the manual changes I made.

Upon closer look, I realized Bob that you set some defaults to these specialized variables from the plugin. All the defaults are actual tags exposed in the pane - which is what I would be modifying. Upon further analysis, I decided that by disabling your plugin at worst it seems I may loose some of the functionality where you plug into the filename ‘feat.’ and the name of the featured artist. Given that I don’t care much for the whole ‘featured’ and since it makes filenames longer anyway, I am willing to loose this functionality by disabling the plugin. Conversely, by disabling the plugin, I completely it seems eliminate the issue of the naming script not being aware of manual changes, which solves my issue.

So it is a tradeoff. Hopefully whomever comes across this it helps them in understanding the structure of the picard, plugins and your excellent naming tagger script, Bob.

Thanks a lot!

1 Like

@rdswift - Bob, not sure where is the appropriate venue to report this. But I believe your naming script has a bug. I have been using it a lot past few days and came upon a scenario where what you describe in comment is incongruent with your code.

The bug concerns how the filename is formed for various and unknown artists. In such cases, the code will incorrectly write out at the end of the filename [feat. Artist Name], where it should just write [Artist Name].

Let me point it out here:

Starting on line 261, this is what you comment says. Pay attention to the ‘various’ and ‘unknown’ artists

Process as Standard
Formats: /~ A ~/Album Artist/[year] Album/Disc-Track Title [feat.]
/~ # ~/Album Artist/[year] Album/Disc-Track Title >[feat.]
/[Various Artists]/[year] Album/Disc-Track Title [Artist]
/[Unknown Artists]/[year] Album/Disc-Track Title [Artist]

The code that actually sets this - the filename, for the ‘standard’ situation is on line 332:

$if($eq(%_nAlbumType%,Standard),$set(_nFileName,%_nTNum% %_nTNT%%_nFeat%))

But you can see your comment deal with basically THREE different scenarios under the situation ‘standard’. Yet your code has only single line, treating them all the same.

This is what I propose to replace line 332. Note that I have not had the chance to test all the scenarios:

$set(_nFileName,%_nTNum% %_nTNT% [%_nFTA%]),
$set(_nFileName,%_nTNum% %_nTNT%),
$set(_nFileName,%_nTNum% %_nTNT%%_nFeat%)

Hope this helps anyone.

Have a look at lines 161 to 174. The value assigned to the %_nFeat% variable is different depending on the situation, thus allowing the actual format to be set in a single assignment (on line 332). All line 332 does is display the content of the variables in a specific order. The content of the variables is set earlier in the script.

I did have a look at that section. Perhaps part of the logic escaped me. Or perhaps me disabling the plugin so I do not get into the issues of the script not picking up my manual tag modifications had an unintended consequence to that part of the script. I don’t know.

Sorry if I sounded the alarm; if you feel it all works fine then great.

Disabling the plugin will almost certainly affect the results from the naming script.