How can I quickly and precisely check whether a given document (PDF in this case) is in one of my 6 databases? To make things more difficult the name of the document in the database might have ben changed from the original name, but the content of course is unaltered.
The Instances attribute works only in the database the document is in:
You could use the See Also & Classify inspector but you need to disable the option to use only the current database and to enable the option to use the contents (instead of tags).
Alternatively a script could compare the content hashes but that’s a rather slow operation as the hash is not indexed.
The following script makes a quick guess based on (1) exact file size and (2) text at the beginning of the document. It runs on the currently open document and outputs an alert message.
(() => {
const app = Application('DEVONthink 3');
app.includeStandardAdditions = true;
const record = app.contentRecord();
const q = `size==${record.size()}`;
const s = app.search(q).filter(r => r.id() !== record.id());
if (s.length === 0) {
app.displayAlert("No duplicate found");
} else {
const frontText = record.plainText().slice(0, 200);
if (s.find(r => r.plainText().startsWith(frontText))) {
app.displayAlert("Duplicate(s) detected. Use See also and Classify to find out.")
} else {
app.displayAlert("No duplicate found");
}
}
})()
This script uses the exact file size as search criteria, which has its limitations. For instance, highlighting a PDF will change its file size. You’ll still need See Also & Classify to check such possibilities.