Some tags may use parentheses in their name. (the tag itself, not the content)
E.g. “drums (drumset)”
When trying to use such a tag in a script, Picard throws an error because of these parentheses.
Is there a way to escape these parentheses so you can use such tags in a script?
Have you tried using a backspace? I use it in my file naming script, and it should work in regular scripting as well. Though I am a bit confused, you example drums (drumset) is an example of a tags contents, is it?
Yeah, I tried something like this:
$set(performer:drums,%performer:drums*(drumset*)%)
(I replaced the backslashes with *, because they get removed when posting them)
This is an example of a recording that uses such a tag:
Works for me, I just got the name wrong. It is “drum set” with a space. You also probably don’t want to have both the “performer:drums” and “performer:drums (drum set)” tags, if so use $unset on the second. This works for me:
No, because a space is not really a special character in Picard. You can use a space without problems, $set(artist,Michael Jackson) works as expected.
The reason the space caused problems was because it was part of the variable name, and the simple syntax to access a variable is using %somevariable%. But this syntax is only valid as long as there is no space in the variable name, %some variable% is invalid. But for these cases there is the $get function. Using $get(somevariable) is equivalent to the percent sign notation, but now $get(some variable) works as well.
You can do other things with $get as well. E.g. you can access variables that have a special character (with special meaning for Picard’s scripting, like %, $ or parantheses etc.) in their name. E.g. it is totally possible to create a variable with a percent sign with e.g. $set(\%,percent), but you only can access it with $get(\%)
Ah yes, I overlooked that too. Now it works great. Thanks!
If I understand correctly, the $unset function should be read to do something like ‘prevent writing’, and not actually as doing any ‘unsetting’.
What I mean is, if I run the script on existing files, $unset(performer:drums (drum set)) will not do anything, and the “drums (drum set)” tag will remain present.
Are you aware of a script function that can delete specific tags in existing files?
(I am very reluctant to use the atom bomb-like “clear all tags” option)
.
PS
And thanks for explaining $get.
The official Picard documentation says:
$get(name)
Returns the variable name (equivalent to %name% ).
But as you explained very well, that’s incorrect. It’s not exactly equivalent.
I think unset is just fine, that’s what it does. After you have $unset a variable it is like you never actually $set it before.
What is missing currently is a function to actually mark a tag as deleted. I have submitted such a function for review, see PICARD-1344. Due to some other issues with deleting tags this function won’t unfortunately work as expected on current Picard 2.0.4, but it will work properly in the coming release (probably 2.1).
The word unset is probably a bit dependent on language or interpretation.
(and I am not native a native English speaker)
I personally interpret it as undoing/un-setting/removing something that had been set/entered before.
And that’s one of the things that gave me a hard time understanding scripting when I began.