I’d like to write a script that does something with groups that have a certain tag. The following framework is very inefficient for large databases, and currently doesn’t even work (it gives the error “Can’t make groups of item 1 of every database into type reference”). Can someone point me to an example of how to do this correctly, or better yet, a more direct way of finding all groups that have a specific tag?
tell application id "DNtp"
try
repeat with currentDatabase in databases
repeat with currentGroup in (groups of currentDatabase)
repeat with currentTag in (tags of currentGroup)
-- do something
end repeat
end repeat
end repeat
on error msg number err
if the err is not -128 then display alert "DEVONthink Pro" message msg as warning
end try
end tell
Creating a global smart group would indeed be a great solution, but how do I get ahold of that smart group from within an AppleScript script? If I create a global smart group with the name “testgroup”, the following returns an empty list:
tell application id "DNtp"
search "testgroup" within titles
end tell
```There must be a way, and it probably doesn't require doing a search, but an hour of looking for suitable AppleScript examples in these forums have yet to turn up an example to help me figure it out ....
The goal is to be able to run a script that invokes “deconsolidate” on certain indexed groups that have been tagged suitably. Regular invocation of the script can be handled externally; I happen to use Keyboard Maestro for a similar purpose (c.f. https://github.com/mhucka/devonthink-hacks/tree/master/update-indexed-groups) but it could be done in other ways too. The indexed groups may be located at arbitrary nesting levels in a database, hence the need to find them somehow.