2-3 months ago I had some question about filtering [which at first I wanted to fix in a form of a column showing me an error]
Unfortunately I can not find that thread, but the conclusion the was that I can simply use in the filter expression like GENRE HAS ##0 AND NOT GENRE HAS ##5
GENRE HAS ##5 AND NOT GENRE HAS ##0to find all the files that have for example ##01value, but do not have the also needed 50-something value like for example ##53
And so it works. But more complicated code GENRE HAS ##0 AND NOT GENRE HAS ##1 AND NOT GENRE HAS ##2works not
Right now I need my files to have 10-someting, 20-someting and 30-someting value at the same time, if one of this values is present [not having all three of them, as they are related to each other, is not an issue]. For example ##44 ##70 ##99and ##12 ##21 ##39and ##13 ##24 ##31are correct;
but ##12and ##12 ##21and ##24 ##31and ##31and ##31#44 ##70 ##99have all an error [of not having all three required values at the same time]
This finds some errors, but not for example ##22 ##38where an ##1X value is missing
No, it was putted as something positive [truth]
Combinations of errors are: ##1X is present but ##2X is not present
##1X is present but ##3X is not present
##1X is present but ##2X is not present and ##3X is not present
##2X is present but ##1X is not present and ##3X is not present
##2X is present but ##1X is not present
##2X is present but ##3X is not present
##3X is present but ##1X is not present
##3X is present but ##2X is not present
##3X is present but ##1X is not present and ##2X is not present
Summing up:
no ##1X and no ##2X and no ##3X at the same time is correct
if one o them is present, the other two also have to be
##0X, ##4X, ##5X, ##6X, ##7X, ##8X, ##9X sometimes will be present, and sometimes not
The examples you gave before did not transport any semantics, i.e. I cannot see any meaning in the numbers. I have no genre called ##31.
So I have to go by the formal aspects.
I think you got the idea of the MATCHES operation. I bet, you can adapt it according to your needs.
A filter like %genre% MATCHES "^##1\d+$"works for me [in 1/3 way of what I need], by showing only files with ##1X in GENRE tag [where X is a single digit from 0 to 9]
A filter like %genre% MATCHES "^##2\d+$"works for me [in 1/3 way of what I need], by showing only files with ##2X
So why does a filter combining those two %genre% MATCHES "^##1\d+$" AND %genre% MATCHES "^##2\d+$"does not work, by showing only files with both ##1X and ##2X; while at the same time a filter like %genre% MATCHES "^##1\d+$" OR %genre% MATCHES "^##2\d+$"works, by showing only files who have either ##1X or ##2X?
You must not mix the plain language "and" with a logical "and"
The not working filter looks for genres that have a length of just one ##xy but has the ##1x and the ##2x at the same time - this is not possible, obiously.
So you have to use OR as logic operator.
The full filter goes like this (%genre% MATCHES "##1\d" AND %genre% MATCHES "##2\d" AND NOT %genre% MATCHES "##3\d") OR (%genre% MATCHES "##1\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##2\d") OR (%genre% MATCHES "##2\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##1\d")
And now I would like to use it in a function, so that I can present it in a form of another error themed column [most suitable for my workflow]. Unfortunately, a code like this $if((%genre% MATCHES "##1\d" AND %genre% MATCHES "##2\d" AND NOT %genre% MATCHES "##3\d") OR (%genre% MATCHES "##1\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##2\d") OR (%genre% MATCHES "##2\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##1\d"),'GENRE ERROR','GENRE OK')distinguishes [says ERROR or OK] only for two case: there is some value in GENRE tag or there is none, as if without looking at te content
I don't understand, why it works perfectly in a filter, but in a function it "works" bluntly [in a only YES / NO way]. Wrong function?
This works only for a single value cases; it way that when there is only >>##1X<< or only >>##2X ##2Y<< or only >>##3X<< is says ERROR as it should
But when there is >>##1X ##2X<< or something like >>##2Y ##33<< is wrongly says its OK, when in a mater of fact it is 2/3 OK [because the value from third group is missing]
And also any other value than >>##1X<<, >>##2X<< and >>##3X<< causes it to say, there is an ERROR, because it apparently views everything other that values from those three groups as something that should not be there. At the same time the filter expression does not have this issue [and so it works for my system, in which GENRE has even words in it like >>##ACTION<<, and no only values like >>##14<<, >>##24 ##37<< or >>##14 ##24 ##33<<]
I have checked the given formatstring against test files, which have been setup as you have described the rules, see following test cases ...
matching ...
##11 ##12 ##21 ##22
##21 ##22 ##31 ##32
##31 ##32 ##11 ##12
not matching ...
##11 ##12 ##21 ##22 ##31
##21 ##22 ##31 ##32 ##11
##31 ##32 ##11 ##12 ##21
Did I misunderstand the rules?
Check out the long complete formatstring for possible writing error, while transferring the string from Forum post here into your target Mp3tag application.
Please check out, whether both filter expressions give the same and correct result:
(%GENRE% MATCHES "##1\d" AND %GENRE% MATCHES "##2\d" AND NOT %GENRE% MATCHES "##3\d")
OR
(%GENRE% MATCHES "##2\d" AND %GENRE% MATCHES "##3\d" AND NOT %GENRE% MATCHES "##1\d")
OR
(%GENRE% MATCHES "##3\d" AND %GENRE% MATCHES "##1\d" AND NOT %GENRE% MATCHES "##2\d")
... is same as ...
(%GENRE% MATCHES "##1\d" OR %GENRE% MATCHES "##2\d" OR %GENRE% MATCHES "##3\d")
AND NOT
(%GENRE% MATCHES "##1\d" AND %GENRE% MATCHES "##2\d" AND %GENRE% MATCHES "##3\d")
No, you did not; they truly are quite simple as those samples above
But in every one of those sample there can also be some more stuff like
##66
##66 ##90
##99 ##ACTION
##TRAGEDY ##ACTION ##80etc., which has nothing to do with the
##1X
##2X
##3Xvalues [and should be omitted by when looking for errors among those three groups]
So the rule is: ##1X / ##2X / ##3X don't have to be, but if they are they have to be all together; and there can be also some other ##stuff, which is of no concern
The first one [mine] works half way
That old filter code should be extended from (%genre% MATCHES "##1\d" AND %genre% MATCHES "##2\d" AND NOT %genre% MATCHES "##3\d")
OR
(%genre% MATCHES "##1\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##2\d")
OR
(%genre% MATCHES "##2\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##1\d")to the form of (%genre% MATCHES "##1\d" AND %genre% MATCHES "##2\d" AND NOT %genre% MATCHES "##3\d")
OR
(%genre% MATCHES "##1\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##2\d")
OR
(%genre% MATCHES "##2\d" AND %genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##1\d")
OR
(%genre% MATCHES "##1\d" AND NOT %genre% MATCHES "##2\d" AND NOT %genre% MATCHES "##3\d")
OR
(%genre% MATCHES "##2\d" AND NOT %genre% MATCHES "##1\d" AND NOT %genre% MATCHES "##3\d")
OR
(%genre% MATCHES "##3\d" AND NOT %genre% MATCHES "##1\d" AND NOT %genre% MATCHES "##2\d")
The second one [yours] seems to work 100% correct
And now I see how that second one shows the overall rule in more clearer way; a as such is better
So now I have compiled twice this time the
into one long continous columns value $ifgreater($add($if($eql('110',$iflonger(%GENRE%,$len($regexp(%GENRE%,'##1\d',)),'1','0')$iflonger(%GENRE%,$len($regexp(%GENRE%,'##2\d',)),'1','0')$iflonger(%GENRE%,$len($regexp(%GENRE%,'##3\d',)),'1','0')),1,0),$if($eql('110',$iflonger(%GENRE%,$len($regexp(%GENRE%,'##1\d',)),'1','0')$iflonger(%GENRE%,$len($regexp(%GENRE%,'##3\d',)),'1','0')$iflonger(%GENRE%,$len($regexp(%GENRE%,'##2\d',)),'1','0')),1,0),$if($eql('110',$iflonger(%GENRE%,$len($regexp(%GENRE%,'##2\d',)),'1','0')$iflonger(%GENRE%,$len($regexp(%GENRE%,'##3\d',)),'1','0')$iflonger(%GENRE%,$len($regexp(%GENRE%,'##1\d',)),'1','0')),1,0)),0,'GENRE OK','GENRE ERROR')
while at the same time having
(%GENRE% MATCHES "##1\d" OR %GENRE% MATCHES "##2\d" OR %GENRE% MATCHES "##3\d") AND NOT (%GENRE% MATCHES "##1\d" AND %GENRE% MATCHES "##2\d" AND %GENRE% MATCHES "##3\d")putted in the filter
The result was that both times the filter was showing correctly what it should [only ERRORs], but column with the compiled code showed some of those ERRORs as being OK. For example ##11 ##12 ##13 ##ACTION
##22 ##23 ##38 ##99
In those two cases, there would not be an ERROR, if they looked like this