obj import and then save to blend file

Now Ihave manage to do this,
But the save command is not working, anyone that can tell me how it should be,
(The script imports obj from folder, then save a new blend file (not working) then deletes all imported parts)

import os
import bpy
# put the location to the folder where the objs are located here in this fashion
# path_to_obj_dir = os.path.join('C:\\', 'Users', 'YOUR_NAME', 'Desktop', 'OBJS')
path_to_obj_dir = os.path.join('C:\Temp\obj')

## get list of all files in directory
file_list = sorted(os.listdir(path_to_obj_dir))
# get a list of files ending in 'obj'
obj_list = [item for item in file_list if item.endswith('.obj')]
# loop through the strings in obj_list and add the files to the scene
for item in obj_list:
    path_to_file = os.path.join(path_to_obj_dir, item)
    bpy.ops.import_scene.obj(filepath = path_to_file)
    bpy.ops.wm.save_as_mainfile(filepath="C:\Temp\obj	est") # This is not working what should it bee instead?
    bpy.ops.object.delete(use_global=False)

//Wilnix

1 Like