run Blender script from command line - need help


I like to run a python script from the command line.
This works fine if I use a extra python file.

blender -b G:\exifblender.blend -s 1 -e 1 -P G:\

But it does not work at all if I want to run a python script wich is saved as text file inside the .blend file.

blender -b G:\exifblender.blend -s 1 -e 1 -P G:\exifblender.blend\Text\
blender -b G:\exifblender.blend -s 1 -e 1 -P G:\exifblender.blend\

both lines above do not work.

Thanks for ideas how to solve this.

Try enabling auto running of scripts on load of file in the preferences.

question: what do you want to achieve eventually?

you can run a blender-internal text block via pyconsole like:

override = {'edit_text':['Text']}

if you wanna execute a text block when .blend loads, give the text block a name ending with .py (e.g. Then tick the checkbox “Register” next to the run script button.

In case you wanna execute code whenever a .blend is loaded, independent of that file, make the code an addon (separate .py file in Blender addon dir) and register a permanent app handler for load_pre or load_post, enable that addon and save as default (so it will be activated by default).

I was wondering, does anyone know how to import an obj and export it as an fbx using a script? That would then be called from the command line.