Checking if a variable is the same across all tracks in a record

Hi,

I have a user script that creates the variable %BRSong% which, based on the actual bitrate of the mp3 file spits out “CBR @ xxxK” or “VBR HQ” or “VBR LQ”.

What I would like to do with the renaming script is:
(a) if all tracks in the folder have the same value for %BRSong% then %BRSong% should be added at the end of the folder name
(b) if not, then instead it should be appended at the name of the file itself

I can clearly easily go with either appending at the end of the folder or at the end of the file - however I cannot figure out how to check on the fly whether all tracks in my album have the same value.

Any ideas / suggestions?

Thanks.

I don’t believe this can be done in a script alone because the tag values are reset when each track is processed. You should be able to do it with a plugin, because they have access to the metadata for all of the tracks. I’m in the process of preparing a document describing how Picard is extended using plugins and scripts. The working draft is available as a Google Doc. This might explain in a bit more detail. Any comments on the doc are appreciated.

1 Like

Interesting - I had a quick look and (for those like me that do not program and rely on snippet collection + trial&error) would be great to see in such a guide some examples and snippet of codes (especially expanding beyond what can be seen in the plugins API)

From your comment I am guessing I need to create a plugin which cycles through the tracks of an album, set the BRSong value for the track, compares it to the previous one and then returns a variable (e.g. BRCommon=True/False) that can be accessed outside the plugin.

I will then be able to use the BRCommon as a switch between the two type of naming conditions.

For the above I am working with a snippet from the “Remove Perfect Album”

```
    def callback(self, objs):
        for album in objs:
            if 
```

Though the example on the API do not seem to go far enough for me to develop the plugin but it’s a starting point.

Thank you.