Annotations Template

Hi.

It seems like the Annotations template originally placed annotations in an Annotations Group. Recently I tried using the template again on (linked) documents in a Group containing only linked documents and the Annotations template placed the annotation file in the same Group as the original (Parent) linked file.

Is there anyway to adjust this new behavior so that the annotations file is once again placed in the Annotations Group. I’ve looked in the package contents of _Annotation___Cmd-Shift-Alt-A but have to admit I’m not too good at deciphering it.

Thanks.

Andrew

I believe the Annotations template has always placed the new document from template in the same groups as the parent document. However, all the Annotation documents also appear in an Annotations smart group, which is perhaps what you recall from before? This is what the smart group looks like, in the event that your database(s) no longer have this smart group.

When the Annotation note feature was first added, it placed Annotation notes in a group of their own. Users requested a change from that placement of Annotation notes.

I think most people prefer placing the Annotation note in the same group as the referenced document. That better fits the likely content of the Annotation note when Classify or See Also is invoked, and in a Name sort will place the Annotation note adjacent to the referenced document.

You can, of course, move Annotation notes to an Annotation group, if you prefer. Or see them in a smart group based on the occurrence of “Annotation” in a Name search.

You may modify the default Annotation template to save the annotation where you wish. To do so:

  1. Locate ~/Library/Application Support/DEVONthink Pro 2/Templates.noindex
  2. Locate the default template (_Annotation___Cmd-Shift-Alt-A.templatescriptd)
  3. Duplicate the default template (command-D) and give the new version whatever name you wish. Note that “___Cmd-Shift-Alt-A” is the keyboard shortcut for the template and you will encounter problems if two templates have the same shortcut – so change or delete the shortcut string from one of the templates.
  4. In Finder, control-click your version of the template and choose “Show Package Contents”. This will reveal the content of the template package (a type of folder).
  5. In the template package, browse to /Contents/Resources/Scripts/main.scpt
  6. Open “main.scpt” in ApplesScript Editor (you might be prompted to also open “System Events” – say OK)

Locate this line in the code


set theRecord to import theTemplateFiles placeholders {|%documentName%|:theFrontmostDocumentName, |%documentLink%|:{|URL|:theFrontmostDocumentURL, |name|:my helperLibrary's localizedString("Click here to view annotated document")}} to theFirstParent

Option 1. either replace it with this code[size=85] (1)[/size]

set theGroup to create location "/Annotations" in theDatabase

set theRecord to import theTemplateFiles placeholders {|%documentName%|:theFrontmostDocumentName, |%documentLink%|:{|URL|:theFrontmostDocumentURL, |name|:my helperLibrary's localizedString("Click here to view annotated document")}} to theGroup

Option 2. or this code


set theRecord to import theTemplateFiles placeholders {|%documentName%|:theFrontmostDocumentName, |%documentLink%|:{|URL|:theFrontmostDocumentURL, |name|:my helperLibrary's localizedString("Click here to view annotated document")}} to display Group Selector

The first Option will place new annotation documents in an Annotation group in the root of your database.

The second Option will always prompt you for the location (group) for your annotation when you create it.

Compile and save the script. Restart DEVONthink. Your version should now appear in the Template menu. (With version 2.6.1 it should appear in the menu automatically as soon as you created the template, but I’m not finding this to be reliably the case. So just restart DEVONthink to be sure.)

size=85 Updated 20131010 the first option; to correct this posting for the issue discussed with @Bernd a few postings below[/size]

Thank you EVERYONE for your quick replies!!!

@Bill_DeVille
I agree it usually makes the most sense, particularly when documents are located within DTP, and Ive used it this way. Since one of my databases now requires a large number of linked documents. I was looking for a suggestion to keep those linked document groups ‘clean’ without extraneous files embedded in the group.

FYI:
The linked documents are scanned/digital images of handwritten foreign language documents and Classify or See Also does not apply to/recognize these linked document groups.

@korm
Thank you. #2 appears to be a nice working solution. I will try to implement it later today.

  • Andrew

@korm:

I tried your first option (set path to “/Annotations”), but the Annotation always lands in my Global Inbox, not in my Annotations group of that database. Any suggestions why this happens?

Thanks a lot!

Well, without trying to bench test this (no time), it could be because of one or more of (1) there’s a typo in your code; (2) there’s a typo in my code ( :open_mouth: ). What is your setting in DEVONthink > Preferences > Import > Destination?

Thanks, krom!

My import setting is set to Global Inbox. When I change the setting, the behavior changes (if I set it to Select Group, I get the same result as if I was using your second code).

But shouldn’t the AppleScript overwrite those Settings? Right now the path I use ("/Annotations") is simply ignored. I tried changing it to another (existing) Group, but it changes nothing.

Anyway, it’s no typo on my side, and since you didn’t actually change much from the original code, I don’t believe it’s a typo on your part. Could it be that AppleScript needs another command to designate the correct path? Simply saying


import to "/path"

might not be correct, but I have no idea what would be correct.

@Bernd

Try this


set theGroup to create location "/Annotations" in theDatabase

set theRecord to import theTemplateFiles placeholders {|%documentName%|:theFrontmostDocumentName, |%documentLink%|:{|URL|:theFrontmostDocumentURL, |name|:my helperLibrary's localizedString("Click here to view annotated document")}} to theGroup

If “Annotations” already exists, this code will merely populates theGroup with the address. Otherwise, it creates and populates.

You might have to declare theDatabase as current database in your script; and obviously do not use theGroup if it conflicts with something else in your script.

Alternative coding:


set theGroup to get record at "/Annotations/" in theDatabase

or


set theGroup to parent 1 of theDatabase whose name is "Annotations"

All of these snippets assume “Annotations” is at the root. Change the path if the group is somewhere else.

Thanks a lot, krom! This works like a charm!