Creating a smart group via Applescript - more than one search criterion?

Been trying to sort this out…

A smart group that has 2 conditions

ALL, Content matches “Red Cross” , Tag is not “Red Cross”

I am trying to write a script that will create several hundreds of these based on a list of tags.
In ScriptDebugger, looking at the properties of this group, I can see the search predicates property as this:

“text:"Red Cross" tags!=Red Cross”

My issue is how to build this in a script (where “Red Cross” is a variable, say, theTag).

I know how to write scripts for search predicates that include only one item, e.g., “tags”, or “text” - but not for >1 predicate.

Any help appreciated!

You’re trying to create several hundred smart groups ?

Yep! My attempt at not doing this is Tinderbox.

I have a database with ~ 10k postage stamps, all with multiple tags (Lightroom keywords converted into tags in DT). I am creating a hierarchy as smart folders, see if this will work for exploring and hyperlinking the stamps and literature, tidbits, etc.

Like so…?

1 Like

Precisely! But, via applescript :slight_smile:

property theTags : {"TEST4"}

tell application id "DNtp"
	repeat with theTag in theTags
		set theTag to (localized string theTag)
		--create record with {type:smart group, name:theTag & " Tag", search predicates:"text:" & theTag "tags:" ! theTag} in current group
		-- create record with {type:smart group, name:theTag & " Tag", search predicates:"text:\"theTag\"tags≠&theTag"} in current group
		create record with {type:smart group, name:theTag & " Tag", search predicates:"text:" & theTag  "tags:"  & theTag} in current group
		
		--text: me tags:! you
	end repeat
end tell

Mine is the product of AppleScript :wink:

set theList to {"Red Cross", "United Way", "DarkSky International"} -- The list for the criteria

tell application id "DNtp"
	set theDestination to (current group) -- Establish where to put the smart groups
	repeat with theCriterion in theList -- Loop through the list of criteria, making one smart group per.
		if not (exists child theCriterion in theDestination) then create record with {name:theCriterion, type:smart group, search predicates:"tags:!" & theCriterion & " text:\"" & theCriterion & "\""} in current group -- Just a check if the smart group already exists and create it, if not.
	end repeat
end tell

My screencap was just making sure the output was the expected one.
And technically theList isn’t needed but it does make things look a little more manageable.

PS: I added the quotes for the text: prefix to ensure you’re matching the exact string. Otherwise, text: Red Cross would match red AND cross, together and separately.

1 Like

Won’t that create an unmanageable mess? What are you trying to achieve?

Vielen Dank!

1 Like

Dear Christian,

There is no way to reduce my mind messiness anyways :slight_smile:
I am moving away from doing this in iThoughtsX or in Tinderbox - both would be great for it, but manually arranging the maps is painful (so I can see all groups and create links, co-explore…)

So I am trying it in DT, via creating smart groups for tags (on this particular database, about 10K postage stamps, each with potentially 5-10 tags such as Country, Decade, Designer, Subject, Tone, Intent, etc).

Also, I am creating smart groups for research material (pdfs, etc) that contain the words in the tag.

And I will be consolidating huge numbers of tag smartgroups into smaller numbers of sets.

I think it will work beautifully.

A glimpse into the budding DT structure… I am capturing the group lists into BBedit, and shaping them into a list for the script Jim so generously fixed.

1 Like

Two smart folders, 1 with references, another with just the stamps (the smart group is grouped by tag “Communist”)


1 Like

Cool collection :heart: :slight_smile:

1 Like

Thanks Jim, it’s been a few years (actually a decade) in the making, and I will in a year launch the site, “Neat Stamps”, where I will be, with collaborators, talking about unique, beautiful, notable stamps, etc. From a Visual Designer / Historian perspective. For that, the collection had to be absurdly eclectic - which is something you don’t see in Philately, actually, but the main criterion was the stamps had - all 10k+ of them, to be what I call “neat” (definition in the site).

I will look at visual design, design curiosities, historical curiosities, intent curiosities, how designers represented certain things, propaganda, the urban and the natural environment, how stamp designers portrayed health and sickness, and many many many more topics.

In attempting to look at 10k+ stamps together, I found striking similarities where you would not at all expect, as well as striking differences in treating a given subject. It’s all very cool.

3 Likes

Could not be done without DT.

1 Like