Can a script make an alias?

When creating a certain class of notes (e.g., a task-note), I’d like to invoke a script that makes an alias of the selected note and stores the alias in a collection-note, typically at the root of my TBX file.

In the past, I employed an agent as my collection vessel. The agent prowls my TBX file in search of notes that match the query (e.g., $Prototype == "_Task").

The appeal of a script over an agent include:
a. Less CPU-intensive. Task-notes occur virtually anywhere in my TBX file. The scope of the agent’s search cannot be narrowed (in my use-case). A script, on the other hand, is a once-and-done affair.
b. Because the collection-note is not an agent, I can make notes inside the collection-note. Processing or surveying a list of tasks usually triggers more tasks that need attention. The new tasks could be made on the spot.

The script would do the following:

  1. change the prototype of the task to _Task
  2. create an alias
  3. move alias to collection-note

The script is triggered on every task-note when it is created. This manual step could be viewed as a drawback: what if one forgets? However, a manual step seems unavoidable. A note has to be ‘marked’ as a task in some manner regardless of whether a script or an agent is ultimately employed. For example, I presently use a stamp[^1] to change prototype to _Task (Step 1). I would simply invoke a script instead of a stamp.

[^1]: my understanding is that stamps can change/set attributes of selected note(s) but cannot make aliases.

Not sure about in AppleScript, but as an interim kludge note that the shortcut ⌘+L will make an alias of the selected item. As the latter is now a sibling (assumed ned in $OutlineOrder) experiment is needed to see to check focus moves onto the alias (it does using the shortcut in the app itself). So, you could pass the shortcut via AppleScript pending a way to do it via direct AppleScript commands within Tinderbox.

Thanks, @mwra. I will give that a try. With Keyboard Maestro or equivalent, one keystroke could then invoke a sequence with desired effect.

1 Like

This might not actually be CPU intensive. True:an agent will look, at least briefly, at every note in your document. But, if the query is easy to resolve, that examination can be quite fast. If you only need the agent to run occasionally, reduce its priority or turn it off when it’s not needed.

Running a script, one the other hand, is fairly costly.