Extract file name from a specific group

Hi everyone! New to DEVONthink, so have things to learn.
I searched both this forum and Keyboard Maestro without luck. The Closest I found to what I want to do is this script:

tell application id "DNtp"
	set theContents to (contents of current database)
	set theContent to some item of theContents
	set recordName to (name of theContent)
end tell

How can I define a specific group instead of the current database? Tried to replace with current group, but get error: “DEVONthink can’t get every content of current group”.

Purpose
I have some quotes (each quote stored as .md file) from books I read etc. Each quote tagged with “quote” respectively. I read in other scripts that you define a group by uuid. Is it possible to use uuid from “quote” tag? I want to extract a random file name of a specific group and later use “say” command to read it to me.

Most quotes are 1-2 sentence long. Are there any limitations about how long file name can be extracted via AppleScript?

Thank you!

Welcome @RDK

It’s late and I’m worn out but perhaps this will steer you a little…

tell application id “DNtp”
   set cg to current group
   set kidList to ((children of cg) whose (type as string is “markdown”))
   set randomKid to some item of kidList
   set recName to name of randomKid
   say recName
end tell

And why are you trying to get the filename? You’re not storing the whole quote as the filename, are you? :flushed:

PS: Check out the Help > Documentation > Automation chapter.

2 Likes

I’m one of them who tries to implement the Zettelkasten method. Don’t know if I’m just wasting time on wiki links or will it actually on some point give interesting outcome? Therefore, each quote saved as an atomic note.

Before DEVONthink, I used drafts and when I imported some drafts into DEVONthink, the title of draft became both file name and part of .md file as well. For this reason, I have quote name as file name and have it this way since then. Switched from Drafts because of lacking for folders. Tags are great, but becomes quickly terrible structure without folders. Can’t imagine how people can have over 10k notes in Drafts. Still, love Drafts thought, Drafts, where text starts. :wink:

Yeah, automation chapter I haven’t looked at so much yet. Have thought read through Take Control of DEVONthink, but. Guessing there are more details in your manual.

Thank you for your sample, got it to work :blush:

You’re welcome :slight_smile: