Adding a keyboard shortcut to the Merge & Delete action

Hi all,

Just what it sounds like above, and apologies if this has been asked/answered already, but I do quite a bit of the merge+delete action when working with collected images and converting items to PDFs. It’s a little tedious going repeatedly to the menu item, but I can’t figure out how to create a keyboard shortcut since the menu item only appears on option-click (and the # of merged items is variable). I’m no expert, so don’t hesitate to tell me there’s a straightforward answer to this!

Welcome @bolman
There is no straightforward answer for this.

The menu command is dynamic, relative to the number of and type of documents selected. If you have two JPEGs selected, it would display as Merge & Delete 2 Images. If you have 10 PDFs selected, it would show Merge & Delete 10 Documents.

If you were only and always merging n documents over and over, it would be possible to set a hotkey, but it would only work in that configuration. If you selected 3, it wouldn’t work.

I worried that was the case, thanks! Using the toolbar button for it speeds things up a little, but being able to assign a shortcut would be splendid. I’ll have to hope for a future version!

You’re welcome!

If you had either Better Touch Tool or Keyboard Maestro you would be able to select menu items using regular expressions. ??

2 Likes

Using Keyboard Maestro there is an option that gets you close.

If you trigger this using a keyboard shortcut, I get the following prompt when I have 3 documents selected in DEVONthink.

You then have the option to select either the top or bottom entry.

Welcome @bolman

You could instead use a script that mirrors the functionality of the built-in menu command. It’s easy to assign keyboard shortcuts to scripts.

I don’t use the merge command much, but from a little testing this seems pretty equivalent:

JavaScript:

// Merge & Delete selected records
(() => {
	const app = Application("DEVONthink");
	app.includeStandardAdditions = true;
	const sel = app.selectedRecords;
	if (sel.length < 2) return;
	app.merge({records: sel, in: app.currentGroup});
	app.move({record: sel, to: app.currentDatabase.trashGroup});
})()

AppleScript:

-- Merge & Delete selected records
tell application id "DNtp"
	set sel to selected records
	if (count of sel) < 2 then return
	merge records sel in current group
	move record sel to trash group of current database
end tell
1 Like