I'm new to Blender and Python, but have programming experience.
I'm writing a script that iterates through all the .stl files in the current directory (current being where the script is), does a few things, then exports them as .fbx files.
When running it from the Scripting screen in Blender, it works great, but I want to run it from the command line.
When I do that it hits an error on this line that grabs the directory where the script resides:
workDir = os.path.dirname(bpy.context.space_data.text.filepath)
The error is:
AttributeError: 'NoneType' object has no attribute 'text'
Why does this work via the GUI and not the command line? Is there a different command I should be using?