I am reading my scripts from a folder with:
import bpy import pathlib for file in pathlib.Path("C:\\awesome\\scripts\\folder").iterdir(): bpy.ops.text.open(filepath = str(file))
Now i can use the scripts in blender itself and may change some stuff here and there. To save a script as a user i can use Alt + S. For scripting this procedure, blender shows a tooltip with bpy.ops.text.save() but i don't know how to define which text i want to save. I guess it will be something like:
import bpy for text in bpy.data.texts: bpy.data.texts.active = text bpy.ops.text.save()
But bpy.data.texts.active is actually not available.
TL;DR: Where to define the active text?