Custom properties as JSON and search using JSONPath

I love DEVONThink and find it to be a high quality product.
Thank you for all your great work!

I have one feature that would make DEVONThink even more powerful – Custom properties and the ability to search them!

My Method
I have implemented my own method for custom properties as follows:
I am storing custom properties as JSON in the comments field. I can run scripts that read and write the entire comments field as JSON data using JSON applescript library found at https://itunes.apple.com/ca/app/json-helper-for-applescript/id453114608?mt=12&ign-mpt=uo%3D4.

Sorting
I implement sorting by requiring the first property of the JSON a fixed key like { “_OrderBy” : “2017-02-01” }. This allows me to sort the files by the Comments field so I can place whatever string I want as the value for “_OrderBy” and the files will be sorted according to that value. This is great if you have multiple date values for files like “ScannedDate”, “ProcessedDate”, etc… A script can be run to set the “_OrderBy” value to one of those other dates.

Searching
I implement searches at a two step process. First I execute a find script over a set of files or the entire database and read their custom properties. If they match my sought criteria, I append or update a custom property to be true, ie { “Criteria123” : “true” }. Second, I create a smart folder with the criteria of Comment matches the exact string of that custom property, ie { “Criteria123” : “true” }.

Links to attachments and other related groups or files
If a file has associated attached files, I store the attachments in a subgroup contained under the same group as the file. I store the links to the attachment group or files in a custom property
ie {“Group_Atch_URL” = “x-devonthink-item://9F75548D-327D-48BA-B3F0-15D662CBD548”}. I execute a script to navigate to the associated files or groups. The limitation here is that there must be a script for each custom property name that contains a link and there can be only 1 link for each name. Example
{
“Group_Atch_URL” = “x-devonthink-item://9F75548D-327D-48BA-B3F0-15D662CBD548”
“Group_Assoc_URL” = “x-devonthink-item://9F75548D-327D-48BA-B3F0-15D662C4256123”
“File_ContainedBy_URL” = “x-devonthink-item://9F75548D-327D-48BA-B3F0-15D6642352341”
}
Because a script needs to know which property contains the link, each property requires its own script. Therefore if a document has multiple attachments you need to link to a group.

Exporting
When a database or folder is exported the custom data will appear in the comments of the exported files.

My Request
Plugins
Is there any way for me to develop a Plugin to show custom properties like the Info window?

JSONPath
Can the smart folder criteria be enhanced to include JSONPath criteria?
See https://github.com/jayway/JsonPath.
Example, if file1 had comment of JSON data of
{
“Author” : “Anne Hill”
“Contributor” : [“John Doe”, “Frank Smith”]
“PrintedDate” : “2016-01-30”
}

A JSONPath of $.file.Contributor[2] = “Frank Smith” would find matches where the second contributor was “Frank Smith”.

Thank you,

-Mark

Very clever.

I would hazard that most readers here have no or little familiarity with JSON. You might want to include a simple sample or image for how you’ve constructed that.

(Since the spotlight comment field is available in, of course, Spotlight, your search scripts should be workable outside of DEVONthink, I would think.)

+1 for custom attributes – a long standing request here – but also one very difficult to implement, I’m sure.

Plugins: there is no plugin architecture now, but scripting of course can take its place. Since you are clever with scripting, you could, for example, write a custom info panel using Pashua and AppleScript or Python. Just as Show Info is invoked by a toolbar icon and a short cut, so can your custom info panel.

Smart Groups and JSONPath. Would there be enough tech-adept customers to even understand what to do with that? Just wondering.

No. A future upgrade will support such plugins and we might publish the API. However, the same upgrade will probably support custom metadata too.

Christian, you guys are incredible!

Very neat indeed.

Or use the URL field to store attachment groups. Has the advantage that you don’t need another script to access them, instead just click URL field in a document.

I can second korm’s recommendation on using Pashua to create UI elements. Its very straightforward and the documentation is excellent. Look at any of my scripts on this forum for examples. An example of a script that uses it is here

Frederiko