Quickest way to check whether a given document is in one of my databases?

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:

As a solution is moving the document in each of the databases and checking its Instances attribute all I can think of. But that’s rather cumbersome…

Many thanks for any pointers!

If you know a short unique phrase in the document then do a toolbar search with scope All Databases.

1 Like

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.

1 Like

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.

1 Like

@cgrunenberg is correct on this. The See Also displays duplicates of a document (something we’ve blogged about).

With content enabled and disabling Current database only

Note the heatmap on the first three items.

  • The first is always the selected document.
  • The other two show they are in different databases/locations and the heatmap is the same.
  • The fourth is a close match but not an actual duplicate so the heatmap is shorter.
4 Likes

It work very well and is pretty nifty.

See, it’s always worth it to ask the experts: They have advice which feels to me incredible elegant and represents out-of-the-box thinking!

2 Likes