Eliminate discnumber and totaldiscs if 0 or 1

Tags: #<Tag:0x00007fcb4bb3d558> #<Tag:0x00007fcb4bb3d238> #<Tag:0x00007fcb4bb3cf40> #<Tag:0x00007fcb4bb3ce00>


I try to remove the content of %discnumber% and %totaldiscs% if the value is smaller or equal to 1 (to only write them into my tags if they are 2 or greater) with the following lines:


Unfortunately, this doesnt work. I get the undesired value 1/1 in my id3 tag DISCNUMBER

What would be the correct syntax?


There’s probably two bugs there. First, $set(...) needs to have the raw name of the variable rather than the value ($set(%discnumber%,0) would try to set a variable named 1 to 0, when $set(discnumber,0) without the % is actually what does what you’re expecting). Second, I think that’s just going to leave the fields empty, but still in the file; $unset(discnumber) will actually remove the fields entirely. The rest of that looks good, though.


Try $if($eq(%totaldiscs%,1),$unset(discnumber))

From this topic: Remove disc number tag


Thank you @mfmeulenbelt
With the command $eq the discnumber will only be unset if totaldiscs has exactly the content 1, correct? Not if totaldiscs is empty or 0 or bigger as 1?

I think I have found a working solution:


The order of this two lines is important.
In the first step the discnumber will be unset if totaldiscs is smaller or equal to 1.
In the second step the totaldiscs itself will be unset for the same condition.


You can get away with only using the $if once. Just put both $unset statements together within it, side by side.


I tried exactly this, but it does not work for me. Can you explain what you did to make it work?


Just go to Picard options, scripting, add a script and paste $if($eq(%totaldiscs%,1),$unset(discnumber)) $if($eq(%totaldiscs%,1),$unset(totaldiscs))
in the box to the right. Apply the settings and reload the release. That should be all.


Yes, I did it, but does not work. Maybe some bug. Thanks for the reply.


I haven’t tested this, but you should even be able to simplify it further by using the single line:


As for it not working, the best guesses I have are that you put spaces or line breaks between an $if( and the following comma (extra characters make it think that the test succeeded every time) or you put the lines in a script with some error that passes the parser but fails when run (rare, but that’s why @mfmeulenbelt recommended making a new script). And, just to be sure, you aren’t putting it in the box on the file renaming page, are you? That will still run as long as you have renaming enabled, but only once you save the file, so you may not see any change.

If none of that’s what’s wrong, I’m not entirely sure what’s going on. I know I’ve had issues with $unset in the past myself, but I forget how I fixed them then. Sorry!