How to search documents with specific texts in their Annotations

Hi all,

I have a question on searching.

How to search pdf documents with specific words in their Annotations (that in the panel of Inspectors, rather than those in the pdf documents)?

Thank you for help in advance.

LC

1 Like

Annotations & Reminders or Document > Annotations inspector? In the first case the annotation is a separate document and can be found like any other document.

Yes. I understand the annotation of a .pdf is saved in a separate .rtf (and they share the same name). I want the search results to show .pdf rather than .rtf so that I can edit their tags/labels.

For example, I want to show all pdfs with “TEST” in their annotations.

This is still unclear.

Are you saying you want to search for annotation files with “TEST” in them but access their linked documents instead?
Or are you looking for PDFs with “TEST” in e.g., a text or note annotation in them?

In the latter case, a toolbar search for text:test kind:pdf is an appropriate search.

The former one. The reason I need to do this is because I use Annotations (.rtf) as the Notes in Bookends where a Note is kind of included in a reference item.

That is not possible to do via search.
You can locate the annotation files with text:test kind:rtf but it’s not going to deliver PDFs as results as they don’t match the search terms.

That is a pity. This seems to be a common need for users who index their PDFs from reference management software.

Anyway, thank you for your quick reply and help! I will check alternative approaches instead.

You’re welcome.

This smart script can be used with batch processing to replicate the referred documents into a group. You could modify the metadata of those replicants, which would apply the changes to the other instances of the documents outside the group.

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			if (name without extension of theRecord) ends with "(Annotation)" then
				set src to (source of theRecord)
				set referredItemLink to (item 1 of (get links of src))
				if referredItemLink is not "" then
					set referredDoc to (get record with uuid referredItemLink)
					if exists referredDoc then
						set tempDir to (create location "/Docs with annotation files/" in (database of theRecord))
						replicate record referredDoc to tempDir
					end if
				end if
			end if
		end repeat
	end tell
end performSmartRule

And the script: Replicate Referred Documents.zip (2.6 KB)

  1. Unzip the attached file.
  2. In the Finder, press Command-Shift-G and paste: ~/Library/Application Scripts/com.devon-technologies.think3.
  3. Drag and drop the AppleScript from Step 1 into the Smart Rules folder in this window.
  4. Quit and relaunch DEVONthink.
  5. Select an annotation file, while browsing or searching.
  6. Select Tools > Batch Process.
  7. Choose the Apply Script action and Replicate Referred Documents and okay running it.

Also note, the replicants can be treated merely as temporary files. When you’re done modifying the metadata, you can move them to the Trash and empty the Trash. This will not delete the other instances of those documents in your database(s).

1 Like

Thank you very much for presenting such a detailed instruction. I will try it later. :+1: :handshake:

You’re welcome.