How to save multiple blender scripts (text-files) at once?
Pathlib

Here is a script that writes all text files in blend with suffix .py to a designated folder.

IMO there is no need to timestamp a file name, since it is given a date when written to or touched.  Timestamp a containing folder name if need be.

import bpy
from pathlib import Path

destination_folder = "/tmp/texts"
df = Path(destination_folder)

#create if doesn't exist
if not df.exists():
    df.mkdir(parents=True, exist_ok=True)

for text in bpy.data.texts:
    p = df / text.name
    if p.suffix == ".py":
        p.write_text(text.as_string())


On getting the path from the blend file name

&gt;&gt;&gt; bpy.data.filepath
'/home/batfinger/Documents/blender/tests/snurf.blend'

&gt;&gt;&gt; Path(bpy.data.filepath)
PosixPath('/home/batfinger/Documents/blender/tests/snurf.blend')

&gt;&gt;&gt; bp = Path(bpy.data.filepath)

&gt;&gt;&gt; bp.stem
'snurf'


If the file is new and has not been saved the datapath will be "". The folder will revert to the base path blender was started from. In my case blender was launched from the terminal in the folder "foo".

&gt;&gt;&gt; dp = Path('')
&gt;&gt;&gt; dp
PosixPath('.')

&gt;&gt;&gt; dp.absolute()
PosixPath('/home/batfinger/foo')