Problem: I have a bunch of .blend files that I want to make the same changes to as quickly as possible.
Solution: Run a python script on each file from the command line?
Here's the python script I'm currently using:
import bpy
#show all layers
bpy.context.scene.layers = ((True,)*20)
#delete the camera, sun and ground
for obj in bpy.data.objects:
obj.select = False
if obj.name == "sun":
obj.select = True
elif obj.name == "ground":
obj.select = True
elif obj.name == "camera":
obj.select = True
bpy.ops.object.delete(use_global = False)
#adjust object locations
for ob in bpy.data.objects:
ob.location[0] = ob.location[0] / 10
ob.location[1] = ob.location[1] / 10
ob.location[2] = ob.location[2] / 10
#save the file and quit
bpy.ops.wm.save_mainfile()
And here's the .bat file:
cd C:\Program Files\Blender Foundation\Blender
blender -b "C:\[path]\file_01.blend" --python "C:\[path]\adjust.py"
blender -b "C:\[path]\file_02.blend" --python "C:\[path]\adjust.py"
The python script works inside Blender, but when I run the .bat file (in admin mode) it just closes. What am I doing wrong?
Bonus: Is there a way to simplify the .bat script so that it just runs on every .blend file in the folder without them being typed out?