Quick and Dirty Bulk converter Python Script

This is a really simple script that bulk converts models using the converters available in the Panda3D SDK.


# Bulk Converter

ModelsDir = "Models"  # Things to convert go here (for me the relative path)

import os

for file in os.listdir(ModelsDir):
    if file.endswith(".bam"):  # Using .bam files to .egg
        scene_model_list.append(ModelsDir + '/' + file)

from subprocess import call

for filename in scene_model_list:
    output_path = os.path.join(filename.rstrip('bam') + "egg")
    call(["Location to converter exe.  In my case bam2egg.exe", filename, output_path])

Just wanted to share this little code snippet for those who don’t like the tedious nature of running the executable in the terminal / command line.

For a little bit of backstory. I used this script in order to convert over 175 models ( of a relatively high poly count ). Doing this by hand would have been miserable. So I would like to thank @rdb for help on the though process.