Tinderbox Forum

Using Agent to automatically export note as a file

I finally have time to dig into TinderBox and wanted to use it to manage my notes.

One of things I have been trying to work out, is how to get an agent to automatically save a note to an external file. I have team members who need to see some of my notes and I just wanted to set a Boolean field to true and then the agent to pick that up, and then export the associated note to a directory so that others could see it.

Is this possible?



Export is a manually initiated task. You can export and agent, so that the contents of the export depends on the agent matches at at time.

But, action code does not—by design—create or delete notes or initiate import, export or explode tasks.

Could I use runCommand to launch an AppleScript ?

In theory yes, you could use runCommand to create a file whose content is the text of a note. If you need the rich text content of a note the effort would be a bit more complex, but doable. I don’t think you’d necessarily need to use osascript to do this.

This method isn’t precisely the same as “export”.

Doing this in an agent would need to be tested to make sure you don’t inadvently fall into a loop that creates a file repeatedly. Maybe an edict or lower priority agent would be better.

1 Like

It occurs to me that @pat’s concept here, while different than the OP’s requirement, contains a framework that could be adapted for the purpose of exporting notes to files.

(And I realize that somewhere buried in my archives I believe I worked up a runCommand export-to-file routine once, several years ago, I’ll look for that.)

1 Like

Yep that’s exactly what I do in Preview your Tinderbox notes using Marked – export code edition

So you just have to decide what you want to export, and then figure out the how. But runCommand is very useful for this sort of thing.

Yep! As Paul W. mentioned, the Publish from Tinderbox to DEVONthink script uses that technique.

I tried two approaches: 1) building an AppleScript using Script Editor, and then running that file using runCommand, and 2) generating the AppleScript within Tinderbox, and passing it to runCommand. My experience is that the second way works better for passing information to the Script (because we simply embed it directly in the script). Reading command-line arguments and file input from AppleScript has been challenging for me. So while constructing the AppleScript from Tinderbox is conceptually a bit of a mind-bender, it ends up being more effective for accomplishing what I need to.

Anyway, what you want to accomplish should be possible… there are going to be simpler and more complex ways of doing it. So, either go for it :slight_smile: or share some more info on what you want to accomplish, and I’ll do my best to share some ideas on how to go about it.

1 Like

Thank you everyone for your guidance.
I now have a really bad agent that exports the information into a text file.
I coded everything in the Agent since I don’t really understand how to use the HTML template export function.

But your advice helped alot and gave me the inspiration to keep fighting it.


@paulavis if you post a sample of your working document, perhaps others may have some pointers.

fwiw I really like using action code (agents & stamps) to do exports. Using action code and exportedString (I think that’s what it’s called) you have a lot of control over where and how things get exported. It’s pretty cool.

1 Like

Ok, you asked for it.

I would really like to be able to specific a string representation of the Created time that

includes the current timezone, but that seems to be missing from the format call.


Setting the file name to save the output to

$Filename = ^title( item )^;
$Filename = $Filename.replace(" “, “_”);

The run command

runCommand("cat > " + “/conversation-txt/”+$Filename, exportedString(this, "Meeting Minutes: ^title( item )^
Date: ^value($meeting_start)^
Attendees: ^value($Attendees)^
Tags: ^value($Tags)
========== Notes ===============

At the end, I set a flag to stop the Agent picking up this one.


Any recommendations or ideas appreciated.

Paul (A recovering developer)

1 Like

One way to export with a timezone: add the time zone to your local long export format in System Preferences, and export with “L”.

Another way: export with RFC8322 dates ($MyDate.format("*") ), and pick off the final five digits. (Wed, 2 Jan 2019 13:34:36 -0500)

Or, use ISO8601 dates ( $MyDate.format("=") ) (2019-01-02T13:34:36-05:00)