In this video, made with Blender version 4.2, I’ll show you a couple of Python scripts that allow you to export the contents of a Blender scene to FBX, including Textures, for all Blender files available in a folder.



Video Transcript

Hello everyone! In this video, made with Blender version 4.2, I’ll show you a couple of Python scripts that allow you to export the contents of a Blender scene to FBX, including Textures, for all Blender files available in a folder.

There are two scripts because the first one script handles the export for the file it's executed on, while the second script runs the first one on all Blender files in the folder.

I created these scripts for a specific need of mine, and I realize it’s a very particular case. However, the tutorial can be extended to other cases, because it actually shows how to run a script, providing it with parameters, without even having to open Blender. Therefore, you can also use this method with different operators and tools than the one used in this case!

Specifically, it is possible to export the content of a blend scene into an FBX file using the export scene fbx function from the operators module, specifying the name of the destination file and other parameters, as indicated by the documentation for this operator in the Blender manual.

What interests me the most is exporting the Textures of the models' materials as well, using the Embedded option with the Copy mode enabled, as I explained in my tutorial on how to export models to FBX with textures.

The two parameters we need to specify, in addition to the destination file name, are Path Mode, which must be set to Copy, and embed textures, which must be set to True.

The function call in the export embedded fbx script will therefore be: bpy.ops.export_scene.fbx(filepath = sys argv -1, path mode='COPY', embed textures = True).

This is the only instruction, after importing the bpy and sys modules, to include in the export_embedded_fbx.py file. The file name is the one passed as a parameter to the script, while Path Mode and Embed Textures allow you to store the images used as Textures within the FBX file.

If we wanted to run this script on a single blend file, all we would need to do is write the following command in the terminal:

blender filename.blend --background --python export_embedded_fbx.py -- filename.fbx

However, I want to run this script for all the Blender files in the folder, which could be many, so I don’t want to manually replace the file names every time!

So, we need another script or a batch file that will run that command for each Blender file it finds in the current folder.

A simple solution is to write the following instructions in another Python file, which we will call, for example, batch export embedded fbx.

After importing the os and subprocess modules, which we need to access the files on disk and to launch the other Python script, we retrieve the path of the current folder by storing it in the variable script dir.

Once this is done, we get a list of all the Blender files available in the current folder.

At this point, we start a loop that, for each Blender file in the list, runs the export embedded fbx Python script, passing it both the current Blender file name and the output file name, with the suffix EMBEDDED and the .fbx extension.

After saving both files to disk, all that’s left to do is run the batch export embedded fbx python script to get the desired result.

Well, I hope this short video was helpful! See you soon!

Search Tutorials

Enter a phrase or multiple comma-separated keywords to search.

This is a personal website and does not constitute a sales channel. The pages dedicated to 3D models document a selection of my work and do not contain offers, prices, purchasing procedures, or commercial links. I am not currently accepting requests for custom work, consulting, or other professional collaborations.


EXTENDED PRIVACY AND COOKIE USAGE POLICY