Batch export Blender files to glTF
This script recursively finds every .blend file below a directory
and exports each one as separate glTF files. It launches Blender in background
mode for each model, so the batch can be run from a normal Python installation
without opening the files manually.
File
batch_export_blend_files_to_gltf.py
Output layout
Each source file gets an export directory beside it. The glTF and
binary data are placed there, while textures are kept in a nested
textures directory.
models/
character.blend
export/
character.gltf
character.bin
textures/
base_color.png
normal.png
Existing directories named export are excluded while searching,
which prevents exported content from being treated as source material.
Usage
Place the script at the root of the Blender project tree and run it with a normal Python installation:
python batch_export_blend_files_to_gltf.py
To export a different directory:
python batch_export_blend_files_to_gltf.py --root path/to/models
Preview the work without launching Blender:
python batch_export_blend_files_to_gltf.py --dry-run
Show the Blender executables the script detected:
python batch_export_blend_files_to_gltf.py --list-blenders
Choose a particular Blender executable:
python batch_export_blend_files_to_gltf.py --blender "C:\Program Files\Blender Foundation\Blender 4.5\blender.exe"
How Blender is found
The script checks, in order:
- The
BLENDER_EXEorBLENDER_PATHenvironment variable. - A
blenderexecutable available onPATH. - Normal Blender Foundation installation directories on Windows.
- Common Blender installation locations on Linux.
- The default Steam library and additional libraries listed in
libraryfolders.vdf.
When multiple discovered installations exist, newer versions are preferred. An explicit command-line path or environment variable remains the most direct way to select a version.
Export behavior
- Uses Blender's built-in glTF exporter.
- Exports separate
.gltf,.bin, and texture files. - Applies modifiers when the installed Blender version supports the option.
- Exports lights, texture coordinates, and normals when supported.
- Uses glTF's Y-up export convention.
- Continues through the batch after a failed model and reports all failures at the end.
Notes
- Run
--dry-runfirst when checking a large project. - The script uses
--factory-startup, so user startup-file settings do not affect the batch. - Blender exporter properties vary by version; unsupported optional settings are skipped automatically.
- Re-running the script writes to the same export paths and may replace previous exports.