If Then Else (All conditions true with Regex OR) Macro (v10.2)
If Then Else (All conditions true with Regex OR).kmmacros (6.2 KB)
Shouldn't the If Then Else action be able to evaluate properly when "all of the following are true" even if there is a matched condition with an OR in the regex?
According to regex101: build, test, and debug regex I checked and the regex I'm using is correct. However, KM tends to disagree as it won't evaluate as expected unless it matches only 1 condition.
So KM is particular regarding regex and I guess has it's own preference as to what is acceptable.
aif|aiff appears to work.
Surely I didn't see that one coming b/c the same expression works using the regex match in search and replace.
Well, when I checked with regex101 I got this:
which obviously wouldn’t work. I would’ve used what you ended up with in the end - but case insensitive -
As an aside, if you’re going to do lots of file path splitting you might want to consider using the
Split Path action which is a lot more concise. Read up in the wiki action:Split Path [Keyboard Maestro Wiki]
Thanks, I do use the Split Path action quite a bit already. It's how I acquired the path, type extension and etc. in the macro example I provided.
More often I do a lot of array, lists and key value pair parsing so if I had more experience and exposure to AppleScript that'd probably be way more intuitive and cleaner for the bulk of the macros I'm creating; but since I don't I have to resort to KM's capabilities out of the box to get things up and running quickly.
I also search the forum library a lot for AS when available. I'll pick up the syntax usages eventually but just need to get things in place quickly right now.
Thanks for the recommendation
Can't see a
Split Path action there...
Maybe, maybe not - only you can say. Personally I have a lot of trouble getting my head around AppleScript so like you I do a lot of gathering from the forum here and the Internet generally when I need help on it. But it is worth persevering since you can augment what's possible with KM by a huge amount using AppleScript and JXA.
Anyway - good luck!