Devonthink - smart groups

Hello,
I’m experimenting with Devonthink, which looks to be an awesome way to work with data. I’m still in the trial phase and wanted to script some tedious task like creating a smart group. (Which are pretty similar to smart folders of the Finder)
I succeeded but the smart folder isn’t a smart folder, something is missing… I tried to add all possible dates from the properties of a working smart group, but… Nothing. If I’m happy to work with this software i’m gonna buy it.

tell application "DEVONthink Pro" to tell current database
	set AllTopics to name of children of record "Topics"
	set AllId to id of children of record "Topics"
	
	activate
	set getProj to choose from list AllTopics with prompt "Choose Project..." default items (item 1 of AllTopics)
	if getProj is false then
		return
	else
		set getProj to getProj as text
	end if
	set dd to 0
	repeat with a in AllTopics
		set dd to dd + 1
		if a is in getProj then exit repeat
	end repeat
	set getId to item dd of AllId
	
	set getCont to children of parent id getId
	set Alltags to meta data of item 1 of getCont
	set KMDkw to item 3 of (Alltags as list)
	
	set theGroup to create record with {name:KMDkw, type:smart group, tags:KMDkw} in parent id getId
	
end tell


This is my current setup… As you can see, the configuration sheet doesn’t display the typical smart folder options… It’s like to have a damn folder. But my code is clear: type should be smart group… Not folder

I need to add that every file in the database has finder tags. So my script should produce automatically all needed tag folders for each @context folder in the list of “topics”

Nobody out there who’s using this useful application? Currently scripting bugs me… I don’t get my mistake in creating a new smart group. Maybe not “my” bug…

Alas, no, you cannot create functional smart groups from AppleScript.

Maybe you should create an account at the DEVONthink forum, and outline your goals in a post there. Pretty sure someone will step up, and show you how it could be done.

Thanks for confirming, alastor933
I’m still using Journler, which is a very old but awesome journal application with all applescript abilities I need.
Sadly Journler crashes in many points! Adding tags, renaming categories, adding URLs text to documents, corruption when adding files to the inbox folder, crash when dragging pictures or media on documents… I found almost for everything a work around but… It’s not a good way to work…

Devon think is great, but its applescript support isn’t really user friendly… And the command to build a smart folder doesn’t work… Or, isn’t supported yet… As the specialists there said.
He he, funny as I have many hundred documents with different tags assigned. I’m not gonna build all those smart folders manually. :frowning:

I know it’s off topic, but I looked already for applications similar to Journler and applescript but didn’t find. Some software suggestion?

From your post at DEVONthink I see you imported tagged files from Finder.
Can’t you use the tags directly?

Not really. I came to DT from Mori, where I had a GTD-ish workflow running. Its A/S dictionary was quite simple as it knew just one object, but its biggest asset was that you could define your own metadata.
In my DT database, tags are contexts, of which I have less than 10. And I figured out how to have custom metadata.

I think I also looked at EagleFiler and Yojimbo, but do not remember why I discarded them.
And I tried hard to like Omnifocus.
Anyway, I don’t think you’ll find an application that can take your Journler workflow 100% unmodified.

Here’s a handler that I made that uses Foundation and Bridge Plus library.

Pass it:

  • List of Records
  • List of Keys

get back a list of items, where the items are grouped by whatever Keys matched


use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use script "BridgePlus"
load framework

-- classes, constants, and enums used
property NSOrderedSet : a reference to current application's NSOrderedSet
property SMSForder : a reference to current application's SMSForder
property NSArray : a reference to current application's NSArray
property NSMutableArray : a reference to current application's NSMutableArray

on makeDUPEGROUP(listofRECS, dupegroupKEYS)
	set dupeARRAY to NSMutableArray's array()
	set sourceARRAY to NSArray's arrayWithArray:listofRECS
	set valuesOFARRAY to SMSForder's subarraysFrom:listofRECS usingKeys:dupegroupKEYS outKeys:(missing value) |error|:(missing value)
	set valuesUNIQUE to NSOrderedSet's orderedSetWithArray:valuesOFARRAY
	
	repeat with i from 1 to count of valuesUNIQUE
		set currentVALUES to (valuesUNIQUE's objectAtIndex:(i - 1)) as list
		set indexMATCH to (SMSForder's indexesOfItems:{currentVALUES} inArray:valuesOFARRAY inverting:false) as list
		set indexSET to (SMSForder's indexSetWithArray:indexMATCH)
		set newOBJECT to (sourceARRAY's objectsAtIndexes:indexSET)
		(dupeARRAY's insertObject:newOBJECT atIndex:(count dupeARRAY))
	end repeat
	return dupeARRAY as list
end makeDUPEGROUP

example use:


set listofRECS to {{plyINDX:2, entINDX:2, title:"Crazy in Love (ft. Jay-Z)", artist:"Beyoncé", depth:1, score:50}, ¬
{plyINDX:3, entINDX:6, title:"Bootylicious Elegance (Nesky Mashup)", artist:"Nesky", depth:3, score:30}, ¬
{plyINDX:2, entINDX:4, title:"No Diggity (Casual Connection 2016 Rework)", artist:"Blackstreet ft. Dr. Dre", depth:3, score:30}, ¬
{plyINDX:2, entINDX:5, title:"Sexy Ladies (Casual Connection Boogie Funk Rework)", artist:"Justin Timberlake", depth:4, score:20}, ¬
{entINDX:4, title:"Return of the Mack", plyINDX:1, depth:-1, score:50, artist:"Mark Morrison"}, ¬
{plyINDX:2, entINDX:3, title:"Bootylicious Elegance (Nesky Mashup)", artist:"Nesky", depth:2, score:40}, ¬
{plyINDX:2, entINDX:4, title:"No Diggity (Casual Connection 2016 Rework)", artist:"Blackstreet ft. Dr. Dre", depth:3, score:30}, ¬
{plyINDX:2, entINDX:5, title:"Sexy Ladies (Casual Connection Boogie Funk Rework)", artist:"Justin Timberlake", depth:4, score:20}, ¬
{plyINDX:2, entINDX:6, title:"Can I Kick It?", artist:"A Tribe Called Quest", depth:5, score:10}}

set dupegroupKEYS to {"title", "artist"}
set theResults to makeDUPEGROUP(listofRECS, dupegroupKEYS)

technomorph
Thanks for your contribution, I’m on Yosemite so, bridgeplus and load framework isn’t needed anymore in my case.
I tried your demo but the script returned me: SMSForder isn’t able to understand subarraysFrom:listofRECS usingKeys

Furthermore I need yet to figure out how to integrate it in Devonthink.

You need to
Use Bridgeplus
SMSForder uses it.

This is an example of
How
To
Group
Things.

You have to
Integrate it yourself