[Feature Request] RTFD as default fileType for notes

RTF is a useful format but RTFD allows for a bit more extensive note taking. I fired up a freeform note from the Sorter and typed in a few sentences then dragged and dropped an image into the window. This, of course, only resolves to a string of the POSIX path instead of resolving to either an alias or, as I hoped, placement of an image into the notes.

Setting the default as RTFD would allow for a simple text only note without having a scenario where you save the doc as RTF then drop and image later which necessitates saving a secondary file as RTFD (and the residual cleanup of the RTF file).

Cheers!
Jim
BLUEFROG

Thanks for the feedback.
Alan

While the default type of a new Sorter document cannot be changed, you can use a custom template combined with AppleScript, an Automator Service, and a Keyboard shortcut to create new RTFD documents in DT, by pressing a hotkey. This technique interacts with DT directly and bypasses the Sorter. It has a few drawbacks and idiosyncracies, but you may find it useful.

Before getting into the details, I’d like to add to BLUEFROG’s feature request one of my own: enhancing the “create record” AppleScript command to allow creating new records based on templates and evaluating placeholders in the process of creating such a template-based document. (And in the process, fixing the apparent bugs in the create record command that prohibit creating trf and rtfd document types, which would have eliminated the requirement to use the Import command instead.)

And, I agree with BLUEFROG that being able to set the Sorter’s default document type to RTFD would be very useful.

==============================
Broadly, the steps are:

I. Create a template for a new RTFD document.

II. Use Automator and Applescript to create a Service that imports the template into the DT group of your choice.

III. Bind the Service to a Keyboard Shortcut.

Here are the detailed steps. It looks like a lot of work, but it’s quite simple, just a bunch of steps.

==============================
I. Create a template for a new RTFD document.

  1. Create a blank document in TextEdit or other text editor that can save as RTFD. If you wish, add boilerplate, set different fonts and text colors, insert tables, and so forth. (See the “Notes” section below if you want to use any of the DT placeholders such as %longDate%.)

  2. Save the file as “New RTFD document.rtfd” in your ~/Library/Application Support/DEVONthink Pro 2/Templates.noindex folder.

==============================
II. Use Automator and Applescript to create a Service that imports the template into the DT group of your choice.

  1. Run Automator.
  2. Select Service and click Choose.
  3. Choose: Service receives [no input] in [any application].
  4. Drag a Run Applescript step into the workflow.
  5. Delete all of the text in the AppleScript step and copy and paste this script:

on run {}
	
	tell application id "com.devon-technologies.thinkpro2"
		set theLocation to display group selector
		import "/Users/**your user name**/Library/Application Support/DEVONthink Pro 2/Templates.noindex/New RTFD document.rtfd" to theLocation
	end tell

end run

In the script, replace your user name with your user name as it appears in Finder. This is the path to the RTFD template document that you created.

  1. Save the Service as “New RTFD Document in DEVONthink”
  2. Quit Automator.

==============================
III. Bind the service to a Keyboard Shortcut.

  1. Run System Preferences.
  2. Click on Keyboard.
  3. In the Keyboard pane, click on Keyboard Shortcuts.
  4. In the left-hand list, select Services.
  5. Scroll the right-hand list to find the “New RTFD Document in DEVONthink” that you created. (If it does not appear, log out and log in, and run System Preferences again. Sometimes new services do not show up in this list. I believe this is a bug in OS X.)
  6. Enable the service by checking its box.
  7. Double-click in the right-hand portion of the service’s entry. A field appears where you will press the keys that you want to trigger the service. Your keystroke must not already be in use.
  8. Quit System Preferences.

==============================
Test your service by pressing the hotkey you assigned to it. A list of open DT databases will pop up: this is the Group Selector. Navigate to the location where you want to save your new document and click OK. A document named “New RTFD Document” will be created in the location you specified. You can drag and drop items into it.

Notes:

  • This has been tested with DT Pro Office; I assume it will work with other DT versions too.
  • DT’s group selector displays only databases that are open.
  • Because this approach uses a template, in DT, you can click the Actions button on the toolbar and select “New from Template.” Your template will be in the list. Select it and DT will use your template as the basis for a new document.
  • When manually creating a new document from a template, DT will evaluate placeholders such as %longDate%. But, since (as far as I can tell) it is not possible create a document from a template using scripting, the script must Import the template, and DT cannot evaluate the placeholder. (Importing is simply copying an item into a DT database.) So, the placeholder text remains in the new document. (Creating a new document from a template might be possible through GUI scripting, but this technique is easily broken.)
  • The new document’s creation date will be the same as the template’s creation date. This is another side effect of Importing the document.
  • DT will not get the input focus after you create the new document. You must navigate to DT to work on the document.

If you ever want to delete this (or any other) service:

  • Disable the service in System Preferences - Keyboard - Keyboard shortcuts by unchecking its enabled box.
  • In a Finder window, navigate to: /Users/your user name/Library/Services
  • Delete the “New RTFD Document in DEVONthink.workflow” service.
  • Empty the Trash.

Perhaps one or more of the more experienced DT scripters can enhance this script. Some things that come to mind are:

  • Prompting for a name for the new document
  • Setting the document’s content to any text selected in any application
  • Changing the creation date of the new document to that date/time it was imported.
  • Setting the input focus to DT after the template is imported.

This is not an ideal solution, but you may find it useful as a workaround.

Interesting, shoolie. I’m going to have to take a closer look at your suggestion. Looks like you have a great grip on automation concepts. (And thanks for the bump on the RTFD. I use it all the time and always pinch myself on the rare occasions I forget to save as to RTFD first. :smiley: )

Cheers!
Jim
BLUEFROG

DT ships with a service called Take Rich Note. It creates a rich text document from whatever is currently selected in an app, and also will create a blank rich text document is nothing is selected in an app. The documentation says that the note is created in the Global Inbox, but in DT Pro Office at least, the Group Selector is displayed and you can choose a group in any open database. So, check in System Prefs - Keyboard - Keyboard Shortcuts that this service is enabled and has a hotkey assigned. (Only problem is many services do not work in FireFox – I am on 10.0.5.) This is the result I was going for with the workflow and AppleScript, so, regarding everything I wrote above … never mind!

This is controlled by the Destination setting of the Import tab of preferences.

There’s a far easier way to create RTFD notes on the fly with DEVONthink, IMO. In DEVONthink > Preferences, set “Take Note Hotkey”. Shut down the Sorter. (Why? Its Take Note panel is the least functional of the four instances of Take Note that DEVONthink supports).

At any time, press the Take Note hot key. The Take Note panel opens and floats on top of wherever you are. You can drag images, PDFs, URLS, text, aliases, files, into the panel. Another other text, causes the format to before RTFD. Add tags. Save to any open group. The panel has some nice features – URLs dragged from browser address bars are added as links that display the page title. Images can be imported from cameras or scanners. Drag an email into the window, you get a link that uses the subject line for the text. There’s a fully functioning contextual menu with the usual
style options, fonts, colors, etc. The services menu is functional too. It’s a nice little feature.

It’s one key press away no matter what you’re doing. (I think it does everything that the interesting procedure @Shoolie described does.) Major annoyance is that the HUD always has a black background, and URLs and some other text look like garbage until the note is saved.

korm:

Thanks for this suggestion. Definitely works more as expected. One smaller addition to the request when using this option…
I don’t often minimize a window, preferring to hide it (weird personal preference). When I invoke the Notes HUD via hotkey it opens the main window as well, unless the window was minimized. It would be nice if the visible state of the main window was accounted for since the window covers things outside DTPO that I may be trying to top into the note. Not a deal breaker by any means but would be nice. :slight_smile:

Jim
BLUEFROG