Lua script for exporting several regions

How can I export every region in one track automatically with a lua script? One region exported to one file.
I figured out how to loop through the regions (at least I get the names) but then I have not seen any example how to export to a wav file with the file path in a variable. (I dont want to open a menu to make manual input for every region, I have 25 regions to export)
Any ideas?
Thanks
Jürgen

Export in general requires interaction and cannot be automated.

You might work around this, eg. bounce each region (to a new region) which creates a new file (session-format, session-rate).

I have export question also and found this which says it will do what the initial goal was https://mim.mbirgin.com/?c=posts&id=236 but it complained something about “string expected, got userdata”

My goal is a bit different. I have basically this kind of project:

  • TRACK1: “BACKGROUND”
  • GROUP: “VOICEOVERS”
    • TRACK2: “VO1”
    • TRACK3: “VO2”

Now I want to automate export process so that there will be:

FILE1: BACKGROUND + VO1
FILE2: BACKGROUND + VO2

Is there a way to do this with LUA?