Would it be possible to create an AppleScript to replicate the selected item to a given group

for example, the AppleScript would

  • create a replicant
  • of the currently selected item in the item list
  • put the replicant into the “DEVONthink Automation” Group

The name of the group is fixed. I would use a different AppleScript for each group I replicate to.

thank you very much !

That’s a simple thing to do in AppleScript. But why not use the Move To popover? If you hold ⌥ you duplicate files instead of moving them, and with ⌘⌥ you replicate.

1 Like

that is what I have been doing for years and I want to evolve to a quicker method, using a palette like I do in Keyboard Maestro

thank you for your reply.

A smart rule (accessible via drag & drop and via Tools > Apply Rule) might be another option.

1 Like

yes, or triggered by a keyword in the item name.

I will give it a try. Thank you very much @cgrunenberg !

or accessible via a Keyboard Maestro macro in my case. Excellent idea !

Sorry to bother you again

How do I specify “currently selected item in item list”. thank you

Drag & drop uses the dropped items, Tools > Apply Rule the selected items.

but instead of drag and drop, I want to create a Keyboard Maestro macro so I need to specify .. of the following are true.

That’s not possible. But maybe the macro could use Tools > Apply Rule > …?

1 Like

I will try. Otherwise, I will simply use keywords in the macro name to trigger the rule. Thank you @cgrunenberg

At a minimum, Kind is Any Document (or a more specific type, like Image) should be the base level criterion.

I would use a single script that presents a list of group options

2 Likes

where how would I find such a script ? thank you for your post

I never used Keyboard Maestro, so I don’t think I can help with that part.

From what I understand you want to replicate, but choose the destination from a small list of groups?

If there is a consistent pattern, it might be possible to completely automate this using a smart rule and avoid issuing any commands at all.

But here is an example AppleScript that replicates all selected records to a (single) predefined destination:

tell application id "DNtp"
	set theDestination to get record with uuid "x-devonthink-item://..." -- item link of destination group
	repeat with theRecord in (selected records)
		if (database of theRecord) = (database of theDestination) then
			replicate record theRecord to theDestination
		else
			display alert "Error" message "Item and destination are in different databases."
			log message "Can't replicate to database \"" & name of (database of theDestination) & "\"" record theRecord
		end if
	end repeat
end tell

Re: Your question to @DTLow – You can try searching the forum’s automation category to see if someone has created a script that deals with a situation similar to yours. I’m not aware of any right now.

Though you generally don’t “find” scripts, you write them :wink:
If you don’t know any AppleScript, you can start learning. Or you can try asking for help!
I do think it shows good manners to search the forum and see if someone has already solved your problem first.

2 Likes

thank you very much. I am extremely grateful for your time, help and wisdom.

It’s not very elegant, but you can use KM to utilize the context menu. You’d also have to update it depending on if the context menu changes. This invokes the context menu, searches for the first 3 letters “rep” in replicate, return to go to the submenu, delete to jump to the search field, enters the group name you want, and assumes it’s the first in the search list and selects that as the group target.

Creating the List

    set theList to {}
	set the end of theList to "Group 1"
	set the end of theList to "Group 2"
	set the end of theList to "..."

Selecting from the list

set theGroup to (choose from list theList with prompt "Select Destination Group" with multiple selections allowed)

1 Like

beautiful !! What are the underlying macros?