Importing a massive number (like hundreds) of OBJ files?

Is there a way to import more than one OBJ file at once, like a specific folder full of them? They all link to the same MTL file and the same images, but importing one by one can be very frustrating with equally frustrating results (having 100 duplicate materials). I’m not very knowledgeable about OBJ files and how to link them together, so I’m kind of stuck.

A batch importing script or an OBJ linking program would be fine for me, if at all possible.

You can import a full directory of objects if you hold shift while selecting the Wavefront format from the menu.

You will see only one new object because all objects are in their own scenes. To join them all in the same scene you can save the Blender file as a library, create a new empty file and import all objects back from the library.

Wow, that’s hidden functionality! You’d have though holding shift whilst selecting files in the file window would’ve been a better idea… or perhaps having the import dialog work out from what filetype you select what type of data you are importing…

I am very interested in how you accomplish this. I am using version 2.45.
I went to Import, Wavefront, then clicked the first file, then held down shift as I selected the others. As you said, there was only a single .obj mesh. I saved the scene as testOBJlibrary.blend. Then I created a new empty file, went to Import, Wavefront, and the import dialog box appeared, I clicked ok. Here is the error message I got:
importing obj “c:\Blender\meshes estOBJlibrary.blend”
passing obj file “c:\Blender\meshes estOBJlibrary.blend”…
traceback <most recent call last>:
File “<string>”, line 831, in load_obj_ui
File “<string>” line 638, in load_obj
ValueError: invalid literal for int<> with base 10: ‘\xc1\xf6\x19\xa1C’

Right clicking on the names (no need for shift) would seem better, but looks like Window.Fileselector() will not pass multiple selected file names to a script.

You are supposed to hold the shift key before the file selector appears, at the time of selecting Wavefront. Then you select a directory, do not click any file name, leave the lower file selector field empty.

You can check if the multiple import worked by looking at the list of scenes.

If you are not afraid to modify scripts, you can have Blender import all the files in the same scene by adding a “#” character before these lines in

scn= stripExt(f) )

That bit actually cleared up a bug that crashed blender if it loaded more than 20 objs. I’ve now loaded more than 1000 with that suggestion, thanks!

Thank you for your specific answer:)

I was just looking for a batch converter for blender when I saw this thread.
So I’m guessing that Blender does not have a batch converter? Convert one file type to another in a batch?

Not technically a batch. You can mass import, though I’m not sure about export…

This is fairly easy to setup with your own python script

import import_obj

import export_obj
import bpy

Just make these run in a loop over some files in a directory (ok, should be added in a generic way, but still its not THAT hard :slight_smile: )

Example (not tested but probably works)

import import_obj
import os

def fileList(path): # Would be nice is this was built into python!
    for dirpath, dirnames, filenames in os.walk(path):
        for filename in filenames:
            yield os.path.join(dirpath, filename)

for f in fileList("/home/ideasman42"):
    if f.lower().endswith(".obj"):

ideas no offense but if that avatar is you, you look way to young to be that smart. i’m twice as old and not near half as good.

Does it still work with 2.62 ?