Tinderbox Forum

Exporting multiple selected notes to a single csv text file?

Need some help here in exporting a number of SELECTED notes to a single csv file?
I can easily export single notes, one at at time using the a template with the code:

This produces a single txt file that I manually do one at a time:
Title of note1,Text of note1

What I want is to select multiple notes and exported all of them to a single csv text file, ex:
Title of note1, Text of note1
Title of note2, text of note2
Title of note3, text of note3

Is there a way to set up an export template to handle multiple selected notes and export a csv .txt file?


In short, no. The simplest method is to use an agent. The agent exports nothing but also exports all its children like so. Let’s assume your template above is called ‘csv-item’. The agent’s export template, ‘csv-list’, is:


Agents (by default) don’t export child notes so exporting the agent will create sone file with your CSV data in it.

If you don’t want to use an agent, perhaps because thee selection doesn’t make an easy query, you can simulate the process with a container. Make a new container and give it the export template ‘csv-list’. Also, on the export inspector un-tick ‘export children’. Now make aliases of your selected notes and drag those into your new export container. Export and then delete the aliases; you might want to keep the container for the next ad-hoc export of this type.

1 Like

Thanks Mark, worked like a charm and does exactly what I want!
Just to clarify, we have 2 new templates:
csv-envelope with the code: “^children(“csv-item”)^”
csv-item with the code: “^value($Name),^value($Text)[return]” NB: [return] is really the return character and not the code

Use the container: either manually placing the alias’s of the notes you want or via an agent.
Set the export template of the container to the “csv-envelope”
set the export templates of the alias’s to the " csv-item"
UNCHECK the export children selection box in the export inspector.

Works as advertised: Question: How could you modify the script if you wanted to print each out as separate individual text files? What script could you apply to the wrapper?

Thanks again in advance

1 Like

Tip, use the forum mark-up for code, otherwise your straight quotes get auto-converted to curly ones and anyone using the result in code will get an error.

I think no, because the whole point of the export selected note feature is to support exporting a single object. Even if that note would otherwise export its children, it doesn’t when using this feature.

Actually, if you set the envelope’s $ExportChildren to true, then Tinderbox will

  1. Export the envelope, which then includes a line for each child
  2. Make a folder for the children
  3. Export each child, using that child’s own export template.

For example, in my weblog each month is a container. The container exports each post in the month in one long page named (say) May2018.html, and each post is exported to a separate page, too.

EDIT: I was being sloppy. This is true when exporting the whole document, but not when exporting only the selected note.