Writing recipes

A recipe is a piece of code that can be run in Magnetron.app. The code is written in a lightweight version of JavaScript and saved in a plain text file in the recipes folder.


A valid recipe starts with a header, which is created or updated automatically when saving the recipe.

Called Functions

The recipe can contain various called functions. This are functions will be triggered by the Magnetron.app user:

- main() will be called once when the recipe is executed.

- onAbout() will be called when the users clicks the about button of the recipe.

- onConfig() will be called when the user clicks the config button of the recipe.

These functions are extremely simple and do not take any variables and do not return anything.

function main()
    echo('hello world!');

Dropped files

A user can add files to the Magnetron.app which the recipe can use as input. For example to convert, process or analyse them. In the recipe you can obtain the list of files using file properties. You can then for example run file operations or interact with online services.

Call 3rd party apps

But by far the most powerfull feature is that you can interact with every command line application you wish.

Process lifetime

Each of these called functions has its own fresh global scope. Therefore if data need to be stored between these calls, like config settings then use memory cache getItems() and setItems().


A few other functions are called as callback to ensure the user stays informed during longer processes. These calls live in the same global scope as the original called main functions. The callback functions include cmd_callback() for cmd calls to external tools. And LevelFileAnalyse_Progress() + LevelFileProcess_Progress() for leveling progress.

Also take a look at the tutorials to quickly learn how to create your first recipes.