Cannot use %comment% as variable value for use later

I’m trying to write a script that strips off (…) from title tags and appends the contents (between the brackets) to the comment tag, appending the existing comment (or create a new tag).
Here is the script,

$set(OriginalComment,$if2(%comment%,No Comment))
$set(comment,$trim($substr(%title%,%_obx%,%_cb%)$if(%OriginalComment%,\, %OriginalComment%,)))

I can see the comment and edit it in Picard (showing the tag as ‘comment’) before the script is run. But when this script runs it always returns with ‘No Comment’

I do not understand why,

$if2(%comment%,No Comment)

when there is a comment, that $if2 still returns ‘No Comment’

Why is %comment% empty when I can clearly see in Picard that a comment has been set???

Sorry, I’m rather new to this… :smile:
As an aside… is there any debugger for the tag scripts short of applying it and cancelling picard every iteration?

It’s an error in the documentation. It should work if you change the line to:

$set(OriginalComment,$if2(%_releasecomment%,No Comment))

I’ll enter a PR to update the documentation.


Thanks, I’ve tried the following,

$set(TestComment,%comment%; %_releasecomment%; %_releasegroupcomment%; %_recordingcomment%; no more)

to check which variables are getting set. However, the ‘Comment’ line shown in picard does not appear in this list.
So what I see is that the ‘Comment’ that appears in picard actually comes from a flac tag that I can see with exiftool. This reports,

Comment : Steven Wilson 2014 Remix

But this doesn’t show up in any of the MB variables, e.g. my TestComment variable has

; super deluxe edition; ; ; no more

That implies that _releasecomment does indeed have a value, but is not the value shown in Picard as ‘Comment’

Seems there’s a little bit more going on if there’s a comment tag in the audio file.

Based on the Tag Mapping information in the Picard documentation, you might be able to retrieve the value as %comment:description%. My understanding of the inner workings of the tag handling is limited at best. Perhaps someone like @outsidecontext can better explain why this may or may not work.

1 Like

I’d need to look into this, but can’t today. Comment can behave a bit special, maybe it is also comment: (with a trailing colon)

Hi again, thanks for taking the time.
So I’ve now made TestComment include your suggestion and also added %comment:% as suggested by outsidecontext…

$set(TestComment,%comment:description%; %comment:%; %comment%; %_releasecomment%; %_releasegroupcomment%; %_recordingcomment%; no more)

But (with another similar case), this only returns,

; ; ; red tray; ; original studio mix; no more
As you can see, nothing in the sections for '%comment:…% etc. and still nothing to match the comment showing in Picard.

This sort of app arcana keeps us on our toes. In this case, I’m now more interested to have the issue logged, so that others who will undoubtedly encounter this have a chance…

What is the tag name that is stored in the file for the original comment? You may have to read it explicitly, and perhaps it’s something as simple as a case mismatch (%Comment% instead of %comment%). I admit that I’m grasping at straws here. :wink:

Well tried that… no luck :frowning: . Updated the TestComment to add the variable name being returned… eg.

$set(TestComment,Comment:%Comment%; comment:decription:%comment:description%; comment::%comment:%; comment:%comment%; _releasecomment:%_releasecomment%; _releasegroupcomment:%_releasegroupcomment%; _recordingcomment:%_recordingcomment%; no more)


Comment:; comment:decription:; comment::; comment:; _releasecomment:; _releasegroupcomment:; _recordingcomment:; no more

The actual comment from Exif this time was…

Genre : Rock
Comment : EAC Flac 1.1.2 -5
Duration : 0:05:14

As I understand you want to preserve existing “comment” tag of the file. I tested this with a FLAC file and $set(OriginalComment,$if2(%comment%,No Comment)) works for me if the FLAC file contains a “COMMENT” tag. The content of the tag will show up in OriginalComment.

A few ideas:

  1. Make sure you are using a recent version of Picard. In Picard before 2.5 the existing file tags where not available in the script.
  2. Try the “View script variables” plugin. When installed and activated you can right click a file and choose “Plugins > View Script Variables” in the context menu. It will show a dialog listing all variable names available.
  3. Alternatively right click the value of the comment tag showing the expected value in the metadata view and select “Edit…”. In the edit dialog you will see the actual internal tag name used by Picard.

For me the name was indeed comment. But maybe you have something else happening here.


Ahh… yes. That’s it. The Mint 20.3 apt package release for Picard is an old 2.3.1, so your observation that file tags are not available now makes it obvious what my problem is.
I’ll try a snap version which is 2.11 (I hope that’s really 2.11 and not 2.1.1).
Thanks for checking this out.


The snap should really be 2.11, if not, shout at me. Be aware that snap is quite restrictive with directory access, though. Outside your home directory you can only access what Snap considers external drives.

Alternatively you might try the Flatpak or try the Ubuntu PPA (, the repository for Ubuntu 20.04 (focal) likely should work also for Mint 20.3.


Managed to get the snap onto the ‘Open With’ context menu. Checked it out, yes 2.11 and now the flac ‘comment’ appears with %comment% and everything is rosy…

It always seems that snaps or flatpaks have some form of ‘gotcha’ that end up taking a lot of effort to figure out. But it looks like they are the way to go if the repositories are so far out of date.
Thanks for your time.