This specification describes the contents of a script file, used for executing a series of commands to transform input data sources and templates into appropriate output.
The file extension for a script file should be ‘.tcz’, short for ‘TDF Czar’, which was a predecessor to PSTextMerge, which was in turn a prececessor to Notenik.
A script file is a text file formatted into five columns, using either tabs or commas as delimiters to separate the columns.
Blank lines, as well as lines beginning with
<!—, will be ignored.
|1||module||Specifies the module to be used to execute the command.|
|2||action||The action to be taken by the indicated module.|
|3||modifier||A field used to modify the effects of the action in some way.|
|4||object||Names the object of the action.|
|5||value||Specifies a value to be assigned, or to be compared.|
The module column may contain any of the following values.
input - Read input rows and columns from a Note Collection or another data source.
filter - Specify one or more filter criteria that will be used to filter the data source to a subset of its original set of rows.
sort - Specify one or more sort fields (major to minor) to be used to sort the data source.
template - Specify the location of a template file to be processed using the data source.
output - Write the filtered, sorted data to an output file in tab-delimited format.
The action for an input command may be either ‘set’ or ‘open’. The set command(s) should precede the open command to which they will apply.
When using ‘set’, the variable to be set would be named in the object column, and the value to which it should be set would be supplied in the value column.
The following variables may be set.
xpltags - Set this variable to ‘true’ to create a row for each tag included in the original row's Tags field. A field called ‘Tag’ will be added to the data source. Set the variable to ‘false’ to bypass tags explosion.
dirdepth - The number of levels of folders to be considered, when reading from a data source that might drill down into multiple folders. The top level folder specified counts as 1.
When using ‘open’, the modifier field specifies the type of data source, and the value field specifies a path to the data source to be opened.
The object field is normally left blank, but an object of ‘merge’ can be used to cause the current data source to be merged with the prior data source, rather than replacing it.
The following modifier values are valid:
dir - Reads the directory entries from the specified directory (including sub-directories, if the dirdepth variable has been set to a value greater than 1).
file - Reads an input text file with columns separated by tabs or commas.
markdown-with-headers - Reads a Markdown-formatted text file, and chunks it up into sections based on its headers. The content of each header will be placed in the Title field, the level of each header (1 - 6) will be placed in a Level field, and all text between this header and the next one will be placed into the Body field.
notenik-defined - Reads a Notenik collection with its fields defined by a template file.
notenik+ - Reads a Notenik collection with a broad set of standard fields.
notenik-general - Reads a Notenik Collection with any set of fields.
notenik-index - Reads a Notenik Collection using the Index field, and generates one row for each index term, containing the following columns.
notenik-split-tags - Reads a Notenik Collection, adds a “Tag” field, and returns one row for each tag (or one row with a blank tag, for Notes with no tags).
xlsx - Reads the first table in the specified XLSX file.
A filter command may have an action of ‘clear’, ‘add’ or ‘set’.
Clears any filter parameters that might have previously been set, so that new ones can be added. A clear action must be followed by a set action in order to actually remove any previously specified filtering rules.
Adds a new filter rule. The object would name the field to be compared as part of the filter. The value field would specify a value to which the object will be compared. And the modifier field specifies the nature of the comparison.
The following modifiers are valid (with all of the different forms on a line producing identical results).
“=”, “==”, “eq” or “equals”
“>”, “gt” or “greater than”
“>=”, “!<”, “ge” or “greater than or equal to”
“<”, “lt” or “less than”
“<=”, "!>“, ”le" or “less than or equal to”
“<>”, “!=”, “ne” or “not equal to”
“()”, “”, “co” or “contains”
“!()”, “!”, “nc” or “does not contain”
“(<)”, “[<]”, “st” or “starts with”
“!(<)”, “![<]”, “ns” or “does not start with”
“(>)”, “[>]”, “fi” or “ends with”
“!(>)”, “![>]”, “nf” or “does not end with”
An action of set causes the previously added filtering rules, specified since the last clear action, to be applied.
Just as with the Filter module, the Sort module uses actions of ‘clear’, ‘add’ and ‘set’.
Clears any sort fields that might have previously been set, so that new ones can be added.
Adds a new sort field, with major ones coming first, and minor ones following. The object would name the field to be used as part of a sort key.
If the modifier field starts with a ‘d’, then the field values will be sorted into descending sequence; anything else will result in an ascending sequence.
An action of set causes the previously added sort fields, specified since the last clear action, to be applied.
A Template command may have an action of ‘webroot’, ‘open’ or ‘generate’.
A ‘webroot’ action causes the value column to be used as a path to the top level of a website to be generated. Template variables of ‘relative’ will then be replaced with a series of ‘../’ strings taking a file reference back to the top of the website.
The file pointed to by the path in the value column will be opened as a Template file.
The previously opened Template file will be processed, generating one or more output files.
An Output command may only have an action of ‘open’.
The current data source, filtered and sorted per any previous relevant commands, will be written to the output file specified in the value column.
A file extension of ‘.csv’ will result in a comma-separated values file being written; any other file extension will result in a tab-delimited file being written.