Link Search Menu Expand Document
Table of contents
  1. Flow - drnewfile
    1. Description
    2. Variables
      1. Used
      2. Created
    3. Termination
    4. Flow
    5. Scripting
      1. Sample Code (AppleScript)
      2. URL
    6. Notes

Flow - drnewfile

Description

Creates a new draft in Drafts based on the content of a file. The path to the file should be passed as the query to this flow, which will then read the content of the file and use that as the content for the draft.

The creation is achieved either using a URL scheme (opening in the foreground), or AppleScript (creating in the background. The flow supports different options for different routes, and the route to be taken should be specified via the OpenDraft variable when calling this trigger.

  • Prefixing content to lines is supported by all methods.
  • Flagging and tagging is supported by the AppleScript (create in background) method.
  • Running an action on the new draft is supported by the URL scheme (create in foreground) method, and will be forced if triggered for a background open method.

Variables

Used

The following variables can be passed in and will be processed by the flow.

Variable Description
query * The file path to the file to use as the content for the new draft.
OpenDraft * Set to true or false and determines the route through the flow.
action The name of an action to execute on the new draft once it has been created if the draft is to be opened.
flagged Set as true or false to indicate if the new draft should be flagged or not, if the draft is to be created in the background.
prefix The text to prepend to each content line.
tags A comma separated list of tags to add to the new draft, if the draft is to be created in the background.

* These are mandatory for triggering this flow.

Created

The following variables are set-up by the flow.

Variable Description
content The (modified) content to populate the new draft with.
NotificationTitle The title to be shown in any completion notification.
NotificationMessage The message to be shown in any completion notification.

Termination

Flow

drnewfile

Scripting

Sample Code (AppleScript)

tell application id "com.runningwithcrayons.Alfred"
	set HOME to do shell script "echo $HOME"
	run trigger "drnewfile" in workflow "com.thoughtasylum.doctordrafts" with argument HOME & "/Desktop/import this.txt"
end tell

URL

alfred://runtrigger/com.thoughtasylum.doctordrafts/drnewfile/?argument=/Users/stephen/Desktop/import%20this.txt

Notes

  • Unlike other triggers in this flow, this trigger does not convert \n or \t to a new line or tab respectively. This is because the content entry is not subject to thre limitations of being entered directlyinto Alfred.