I am almost embarrassed to ask this question after so many years using Devonthink - but I cannot find the answer searching documentation and the only query I can find in the Forums goes back over a decade ( Reading Multiple Files ).
Is it possible to select multiple documents and then have them all open with each one as a different tab in the same window/viewer?
I know it is possible to do this and have each one as a new window; but it would be very convenient to have the option for them to stay in one window but with different tabs.
Can I then move those tabs to a separate window? Devonthink Help suggests I can use Window/Move Tab to New Window but I cannot find that option nor can I highlight multiple tabs with Cmd. Is this response hallucinated?
I am a bit surprised the request has not come up before
Especially as larger monitors and multi-monitors have become more common, being able to have a freefloating window with a set of related documents would be very useful.
Is this doable in a script? I may give that a try.
I, to open several DT4 files selected in different windows, use the following script:
tell application id "DNtp"
set theSelection to the selection
repeat with theRecord in theSelection
open tab for record theRecord
end repeat
end tell
tell application id "DNtp"
if not (exists main window 1) then
display alert "No viewer window is open. Please open one and select files."
return
end if
set theSelection to the selection
if theSelection is {} then
display alert "No documents selected in DEVONthink."
return
end if
repeat with theRecord in theSelection
try
open tab for record theRecord in main window 1
end try
end repeat
end tell
You’re welcome!
I was a bit too quick, though. If you have only one record selected and it’s displayed in the current tab, the script above doesn’t close the original tab. This should do it:
(() => {
const app = Application("DEVONthink");
const sel = app.selectedRecords();
if (sel.length > 0) {
const tab = app.thinkWindows[0].currentTab;
const r = tab.contentRecord();
if (r?.id() === sel[0].id()) tab.close();
const w = app.openTabFor({ record:sel.shift() }).thinkWindow();
sel.forEach(r => app.openTabFor({record:r, in:w}));
}
})()
Is it just that id is not persistent like uuid is, or is there more to it?
But sure, uuid would fill the same role here. It’s just that comparing two object specifiers that look identical doesn’t work, it always returns false. So you have to compare some property instead, at least from what I can tell. (I guess comparing the string from getDisplayString also works). I just went with id since that’s what I saw in the log.