Notification showing document name

Hi,

Just out of curiosity to ask if Devonthink is capable of doing the following:

I have a folder in DT3, and it has a number of documents.

Can I set DT3 to randomly pick a document in the folder and send the name of that document to MacOS notification, at a specific interval, e.g., daily?

Thanks,
Jake

Are you comfortable with AppleScript? It would be pretty trivial to script.

Thanks for the direction. I don’t know AppleScript but good to know it’s possible to do this.

Jake

Ah. It isn’t difficult to learn, even with no programming experience—it is just trial and error.

You’re looking for something like:

property someID : "some-id-number-for-a-DEVONthink-record"

tell application id "DNtp"
	set parentFolder to get record with uuid someID
	set theRecords to the children of parentFolder
	set aRecord to some record of theRecords
	display notification name of aRecord as string
end tell

I haven’t tested this but it shouldn’t be far off from accurate.

A minor correction…

	set theRecords to the (children of parentFolder whose (type is not group))
       -- Filter out groups

	set aRecord to some item of theRecords
       -- There aren't "records" in the list. There are "items".

Also bear in mind, this is dealing with the children in a group, not children in subgroups of the group.

2 Likes

Thanks @ryanjamurphy and @BLUEFROG for the AppleScirpt. :smile:

I modified as Blueforg suggested

property someID : "some-id-number-for-a-DEVONthink-record"

tell application id "DNtp"
	set parentFolder to get record with uuid someID
	set theRecords to the (children of parentFolder whose (type is not group))
	set aRecord to some item of theRecords
	display notification name of aRecord as string
end tell

I tried to save it in the script folder of DT3, and execute it via the script manual in DT.

Sadly nothing happened.

I have a script obtained from someone to rename text file based on what’s written in the first line of the file and it works well through this way. I guess I am missing something here?

Jake

Ah, if you copied and pasted that script as-is, the script has no way to know what group you want to use this on.

As it’s written, the property someID is some-id-number-for-a-DEVONthink-record needs to be specified. Take the group you want to use this with, copy its item link, and then paste the id in that link (e.g., remove the x-devonthink-item:// part) between the quotes of the first line on the script.

1 Like

Thank you for the detail explanation @ryanjamurphy

Just tried and now it works :grin:

1 Like

No problem :slight_smile: