Rendering video sequence editor by scripting I'm trying to render all individual strips that I have in the video sequence editor in separate files automatically. 

I started this script:

import bpy

scene = bpy.context.scene
all_strips = list(sorted(scene.sequence_editor.sequences, key = lambda x: x.frame_final_start))

bpy.data.scenes["Scene"].render.filepath = "/Users/***/Blender/mkv/"
bpy.data.scenes["Scene"].render.image_settings.file_format = "FFMPEG"

for strip in all_strips:
    if strip.type == "MOVIE":
        start = strip.frame_final_start
        end = strip.frame_final_end
        bpy.context.scene.frame_start = start
        bpy.context.scene.frame_end = end
        bpy.ops.render.render(animation=True, use_viewport=True)


but I always get this error:

Traceback (most recent call last):
  File "&lt;blender_console&gt;", line 7, in &lt;module&gt;
  File "/Applications/Blender.app/Contents/Resources/2.79/scripts/modules/bpy/ops.py", line 189, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Could not open file for writing


Is there something wrong with bpy.ops.render.render(animation=True, use_viewport=True), with some context maybe?
It seems that by specifying:

bpy.data.scenes["Scene"].render.filepath = "/Users/***/Blender/mkv/" 

Blender tries to create the file with the directory name (I actually thought that Blender added automatically the filename with the start and end frames...). I changed it to:

bpy.data.scenes["Scene"].render.filepath = "/Users/***/Blender/mkv/" + str(n_strip) + ".mkv"


inside the loop and it now works perfectly.

Kudos to batFINGER for the hint.