Search for Tags in a Number Range?

Let's say I have some files tagged like so: "BPM: 50", "BPM: 75", "BPM: 112", "BPM: 124"

Is it possible to search for: Tags containing "BPM" and a number between 70 and 120?

That search would return the files tagged: "BPM: 75" and "BPM: 112"

Any help would be really appreciated.

You don't say where, but limited testing suggests you could do this in the Finder using a Spotlight search of Tag:BPM AND (Tag:70 OR Tag:71 OR..OR Tag:119 OR Tag:120) (those extra tags may be redundant, my test set isn't large enough to know whether it's picking up the naked numbers only from the Tag or from "Everything").

Which would be horrible to type in full, but quite easy to build using a KM macro then paste into the Search box.

1 Like

@Nige_S, always helping me out. Much appreciated!

So what's the convention for that? The one you gave me works perfectly, but the following didn't find a file tagged "BPM: 66". What am I missing?

Tag:BPM AND (Tag:60 OR Tag:61 OR..OR Tag:69 OR Tag:70)

To be 100% clear -- are you using the same convention as me, and .. means "and generate all the tags in between"? So, in this case:

Tag:BPM AND (Tag:60 OR Tag:61 OR Tag:62 OR Tag:63 OR Tag:64 OR Tag:65 OR Tag:66 OR Tag:67 OR Tag:68 OR Tag:69 OR Tag:70)

Thinking about it over-night, since we're making the list in KM it's no more work to be even more explicit and do

Tag:”BPM 60” OR Tag:”BPM 61” OR Tag:”BPM 62” OR Tag:”BPM 63” OR Tag:”BPM 64” OR Tag:”BPM 65” OR Tag:”BPM 66” OR Tag:”BPM 67” OR Tag:”BPM 68” OR Tag:”BPM 69” OR Tag:”BPM 70”

...which, assuming you're consistent with your spaces, will give a better match.

I just copied and pasted your example and changed the numbers.

Yours:Tag:BPM AND (Tag:70 OR Tag:71 OR..OR Tag:119 OR Tag:120)
Mine:Tag:BPM AND (Tag:60 OR Tag:61 OR..OR Tag:69 OR Tag:70)

It strikes me as slightly more work so I'm curious why the above attempt didn't work the way your example did.

I just tested the below and it does work, so thanks! I'd just like to understand what I did wrong.

Tag:”BPM: 60” OR Tag:”BPM: 61” OR Tag:”BPM: 62” OR Tag:”BPM: 63” OR Tag:”BPM: 64” OR Tag:”BPM: 65” OR Tag:”BPM: 66” OR Tag:”BPM: 67” OR Tag:”BPM: 68” OR Tag:”BPM: 69” OR Tag:”BPM: 70”

Absolutely nothing! My badly-explained example used .. as a stand-in for "and all the other values" because I was too lazy to put in all 51 of them. Eleven I can cope with :wink:

1 Like

Ohhhhh. :joy:

I thought that was a language the Finder understood because you put it as code. Haha! I feel silly.

Ok here's a little macro that generates the search string and uses it to search in Finder:

Logic - Search for BPM Tags in Range.kmmacros (53 KB)

Macro screenshot

Beat me to it! But if I may make a suggestion? You've hard-coded your loop to 10 -- try Local__Plus or Minus * 2 instead:

(I was using a while loop, but I think your way is faster and less computationally intensive...)

1 Like

Ah silly me! Of course. I forgot the range might change. D'oh!


Here's the finished thing: Continue macro after user clicks a particular image - #35 by noisneil

1 Like