Recreating DT2 annotation file experience in DT3

Has anyone written an applescript to recreate the DT2 annotation file behavior in DT3? My workflow depended on it, and I don’t know applescript, so I thought I would just check and see if anyone happened to have done it already or has any advice. Basically, from a file selection, using a keyboard shortcut, I want to go to annotations, select New from Template, open the new annotation file, and then make sure the annotation file is saved in the same group as the original file. I’d like to end up in the open RTF file rather than the small annotations window.

I’ve just tried it out and the old annotation workflow still works — but it’s not provided by default, so you have to set it up yourself.

All you need to do is to copy the one from DT2 into the same relative folder as DT3 and it should work – it even populates the Inspector annotation pane for you in case you want that handy.

The steps:

  1. In Finder, go to Library > Application Support > Devonthink Pro 2 > Templates.noindex
  2. Copy the file _Annotation___Cmd-Shift-Alt-A.templatescriptd to the DT3 templates folder (Library > Application Support > Devonthink 3 > Templates.noindex)

In DT3, you’ll find Annotation is back on the Data > New from Template menu with the same shortcut as before. It will create an annotation to the current document in the current group and open the annotation in a window as it did in DT2.

The difference is that the annotation will now also be available in the Inspector Annotation pane (Control-3) of the source document. You’ll see there’s a slight difference in formatting between the DT2 and the DT3 versions because they’ve made some formatting changes to the new one, to cater for the narrower pane, but it’s still basically the same.

Obviously, as before you can change the basic formatting of the imported template by opening up the file and making changes to the underlying RTF: there’s no need for any AppleScript.

HTH

2 Likes

Thanks for this. It was working great until the last beta (beta 3). Now, when I activate the shortcut, the new annotation file appears according to my template annotation file and then immediately goes blank (i.e. just becomes a blank rtf file).

I checked, and my template is still in Library > Application Support > Devonthink 3 > Templates.noindex > _Annotation___Cmd-Shift-Alt-A.templatescriptd > Contents > Resources > en.lproj > Annotation.rtf

Is there a new template that is overriding this in beta 3? My shortcut still works and the annotation file is still made in the same group as the original selection, just as in DT2.

The old template still seems to work over here. Did you customize the template? A screenshot before/after using might be useful, thanks.

I did customize the template. It is below. The previous template was just the original one.

Now it works sometimes and sometimes the annotation file goes blank. Then sometimes the keyboard shortcut opens the DT3 annotation file and doesn’t save the file in my current group (it saves it in the universal annotations folder, using the default DT3 behavior). I’m not sure what is going on. I don’t think I am doing anything differently. It started with beta3.

Just to test for he “Blank” issue if what you meant is seeing “blank” in the reminder and annotation pane:
I tried using @brookter description to place the annotation template and has no issue in creating and seeing the annotation in the reminder and annotation pane inDT3b3.

However, have you checked whether the URL field of the inspector sidebar fo the source item is empty/avaiilable before you create the annotation note? If for any reason the URL field is occupied before you create the note, the note will still be created but will not link to the source because the field is already occupied. At least that what I experienced.

Just FYI

The inconsistency in the behavior you’re describing makes this difficult to assess.

I would suggest you:

  1. Quit DEVONthink.
  2. Remove the modified Annotation template.
  3. Install the original Annotation template.
  4. Launch DEVONthink and see how it behaves.

ngan was correct - when Finder Comments give an original URL, the annotation file reverts to the blank file instead of my template file. If I delete the Finder Comments URL, my template works. Is there anyway to override this? Many of my PDFs have an original URL from the site they were downloaded from. It will be laborious to delete all of them by hand. Plus, I don’t recall this being an issue in DT2, when I also used many of the same PDFs downloaded from the same sites.

Actually, I spoke too soon. I followed bluefrog’s advice, quit DT3, and reinstalled the original _Annotation___Cmd-Shift-Alt-A.templatescriptd file from DT2. I tried the keyboard shortcut on a file with nothing in the finder comments, and the annotation file opened to the DT2 template and immediately reverted to a blank file. It populated the finder comments with an original URL, which is why I had thought my other files had original URLs in them. The original URL it added looked like "Original URL: https://pdf.sciencedirectassets.com/271238/1-s2.0-S0378377417X00115/1-s2.0-S0378377417302846/main.pdf?x-amz-security-token=AgoJb3JpZ2luX2VjEK… ". Now I am just confused again.

Ok. The problem does seem to happen when the URL field is already populated AND it populates the Finder Comments with the original URL after the problem happens. When the I delete everything in the URL field, I am able to make the template stick and it works as expected. So I am back to my original issue, which is that I have many PDFs with populated URL fields and the the template always worked fine in DT2. Is there anyway to make it work fine with a populated URL field in DT3?

If you simply want to clear the URL field to add annotation note in DT2 way you can consider script 1, if you want to be safe and have no other use in finder’s comment field and is ok to move whatever is in the URL field and append it to the content in the comment field before clearing the URL field, consider script 2.
Disclaimer: I am not technical savvy and are just modifying from another stock script in DT3. The scripts work for me but not necessarily for you. It means that (1) test it with a few items first (with back-up) (2) whatever happens is at ur own risk. It is safer for u to filter out the items with non-empty URL and choose a few items, duplicate them, and test.

Script 1: just clear the URL field for a list of items you select

tell application id "DNtp"
	try
		set theSelection to the selection
		if theSelection is {} then error "Please select some items."
		
		repeat
			set theTag to display name editor "REMOVE ALL TAGS" info "Type YES to confirm"
			if theTag is not "" then exit repeat
		end repeat
		
		
		
		if theTag is "YES" then
			repeat with theRecord in theSelection
				
				set URL of theRecord to ""
				
			end repeat
		end if
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

Script 2: move whatever is in URL field and append it to the finder’s comment field, then clear the URL field

tell application id "DNtp"
	try
		set theSelection to the selection
		if theSelection is {} then error "Please select some items."
		
		repeat
			set theTag to display name editor "REMOVE ALL TAGS" info "Type YES to confirm"
			if theTag is not "" then exit repeat
		end repeat
		
		
		
		if theTag is "YES" then
			repeat with theRecord in theSelection
				
				if URL of theRecord is not "" then
					set theURL to the URL of theRecord as string
					set oldcomment to the comment of theRecord as string
					if oldcomment is not "" then
						set newcomment to oldcomment & "," & theURL
					else
						set newcomment to theURL
					end if
					set URL of theRecord to ""
					set the comment of theRecord to newcomment
				end if
			end repeat
		end if
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

Thank you for this! The script is working well. However, it has a strange behavior. I am using the second script. It works when I am viewing the info panel on the right hand side and I select an item, run the script (and so remove the URL), select cmd-alt-shift-A – I get my template annotation file. However, if I am viewing the info panel, select an item, run the script (and so remove the URL), then switch to the Annotations and Reminders panel on the right hand side, then select cmd-alt-shift-A — I get the bad behavior where the template appears and then disappears and goes blank. This is very strange. All it takes is switching my view of the right hand panel - I have no good explanation for this. Do you have any suggestions?

I just confirmed that it does the same thing when I use the first script and nothing is put in the finder comments.

Hi
(1) The scripts are only meant to do one thing only: clear the URL of many items in batch mode.
(2) The annotation related issue is beyond my level, perhaps u should wait for the developer’s feedback.
(3) DT3 is still in beta, perhaps we should wait for the next beta or after the first final release to know what options are available. I myself prefer the old way of putting annotation notes in the same group of linked documents, but can also learn to adapt to the new way.

Since this thread seems to be the more technically involved thread than the other posts on the file annotations, I’m posting my reply here.

  1. I would describe the shift in annotation file experience from DT2 to DT3 as a move from a template to a feature. Because annotations now have their own submenu within the inspector (reference image 2 in DT3b3 Annotations - Disambiguation )
  2. With the restructuring, the rtf file that drives the Annotations template in DT3 is no longer in the Data>New From Template>Open Template Folder, but contained within the DT3 app itself. The text formatting and some of the placeholder commands in the DT3 annotations.rtf are different than DT2 annotations.rtf; so if you want the formatting to appear clean in DT3, you would need to replicate the text formatting and placeholders from the DT3 annotations.rtf .
  3. The DT2 annotations template script will create a smart group to find the annotations, while leaving the newly created annotation in the same folder as the file being annotated.
    3a. In DT3 the action of the annotations submenu places the annotation in its own group called Annotations, so annotations do not build up in the same folder as the file being annotated.
  4. As has been observed here and in my other post here it’s fairly easy to drop new templates into DT3, but this does not modify the annotations feature.
    4a. Possibly if the annotations feature allowed for the modification or addition of its siloed annotations.rtf file, we could use other templates that leverage the way this feature acts.
    My suggestion for future releases would be to place the DT3 annotations.rtf file in a place where the user can easily modify it or add additional templates while preserving the new action of this feature.

This is indeed planned for future releases.

Looking forward to it!

Checking in to see if there’s any progress here. I’d like to be able to link an existing markdown document as an annotations file.

For reference, here’s the workflow I’m using for highlighting and summarizing articles:

  • In Safari, clip the web page as a markdown or web archive into DT
  • Back in Safari, select an interesting section of text, right-click -> Services -> Create Markdown Document
  • For additional quotes, select new text sections, right click -> Services -> Append Plain Note (adds to the same Markdown document)

The result is a markdown document that’s an effective summation of the article.

–> Once I’ve clipped & appended the relevant quotes and perhaps added any of my own notes, I’d like to be able to link this markdown file as the annotations file for the original web archive, linking the two together with the special functionality & privileges of the annotations features in DT3 <–

As it is right now, I have to copy & paste the markdown into the annotations field, reveal the new annotations file (now marked as a “duplicate”), and re-create any tags and other metadata from the original appended markdown file.

I’m open to suggestions on other workflows if I’m missing something here!

You can’t just connect any random document as an Annotation file.

Technically you could drag and drop the Markdown file to the Annotations section of the Reminders & Annotations inspector, but that would generate a new Annotation file. This may or may not be desirable. However, it would not be updated by subsequent calls from the Append service you mentioned since the Annotation file is a new file, distinct from the original.

It is possible to script something, however there is a danger since using the Remove option would send the faux Annotation file to the Trash. Also, scripting it would not be elegant unless it was thought through well.