'unpack' scripts (2.5x)

Is there a way to save all scripts in a .blend file to disk?
I have an old blend i downloaded from somewhere, and since its from 2.42 just about every script needs ‘import GameLogic’ added to the top, and some default find / replace done.
I’m thinking this would be much much easier if i was able to do it from the command line using sed or something.
I have 2.49 if its possible from there also?

There was a script or program floating around that converts 2.49 scripts to 2.5x. Unfortunately, it seems to have been removed. Oh well; in any case, there’s no built-in method to convert built-in Blender scripts to external file - I think you have to manually save each one. HOWEVER, you can create an add-on to do that for you. You’d have to loop through each file and save it again as a file with the script’s name to disk.

Off the top of my head. 2.49.


import Blender

for text in Blender.Text.Get():
    path = Blender.sys.expandpath("//" + text.name)
    handle = open(path, "w")
    handle.writelines([line + "
" for line in text.asLines()])
    handle.close()

Should save all texts to same directory as .blend.