Looking for best method to implement a basic file import

Hi, I’m very new to creating addons and python in general so please forgive me if I use incorrect terms and jargon

I’m looking for the best way to import a bunch of files(image files) in Blender,

the way the code currently work is it makes use of the import helper class that selects the relevant file for import. and then the user would click import running the execute function.

this execute function then calls another function that is decoding the file and creating the mesh within the 3D enviroment, in the function it needs to make use of an unknown amount of images and the images have to be selected manually by the user.

What I need to do is find a way to select and import each image (it would work best if each image is imported one by one, rather than be a mass import… Unless it is possible to assign each image to their corresponding index in the import window itself) I just need to obtain the file location of the selected image. I was hoping there is a way to do this with a currently existing Blender interface that acts like a method where you just call it, it brings up the import window, you press import once you have selected the image and then the method would return the file location.

class IMPORT_OT_lol(bpy.types.Operator, ImportHelper):
bl_label="Import LoL"
bl_idname="import.lol"

SKN_FILE = props.StringProperty(name='Mesh', description='Model .skn file')
SKL_FILE = props.StringProperty(name='Skeleton', description='Model .skl file')
DDS_FILE = props.StringProperty(name='Texture', description='Model .dds file')    
MODEL_DIR = props.StringProperty()
IMPORT_TEXTURES = props.BoolProperty(name='ImportTextures', description='Loads the textures for the applied mesh', default=True)
CLEAR_SCENE = props.BoolProperty(name='ClearScene', description='Clear current scene before importing?', default=True)
APPLY_WEIGHTS = props.BoolProperty(name='LoadWeights', description='Load default bone weights from .skn file', default=True)

files= props.CollectionProperty(name="File Path",type=bpy.types.OperatorFileListElement)

def draw(self, context):
    layout = self.layout

    box = layout.box()
   
    fileProps = context.space_data.params
    self.MODEL_DIR = (fileProps.directory).decode('utf-8')

    for file in self.files:
        selectedFileExt=path.splitext(file.name)[-1].lower()
        if selectedFileExt == '.skn':
            self.SKN_FILE = file.name
        elif selectedFileExt == '.skl':
            self.SKL_FILE = file.name
        elif selectedFileExt == '.dds':
            self.DDS_FILE = file.name

    box.prop(self.properties, 'SKN_FILE')
    box.prop(self.properties, 'SKL_FILE')
    box.prop(self.properties, 'IMPORT_TEXTURES')
    # box.prop(self.properties, 'DDS_FILE')
    box.prop(self.properties, 'CLEAR_SCENE', text='Clear scene before importing')
    box.prop(self.properties, 'APPLY_WEIGHTS', text='Load mesh weights')    
    
#Here is the execute function
def execute(self, context):
    #Here the function that performs the mesh creation is called
    import_char(MODEL_DIR=self.MODEL_DIR,
                SKN_FILE=self.SKN_FILE,
                SKL_FILE=self.SKL_FILE,
                DDS_FILE=self.DDS_FILE,
                CLEAR_SCENE=self.CLEAR_SCENE,
                APPLY_WEIGHTS=self.APPLY_WEIGHTS,
                IMPORT_TEXTURES=self.IMPORT_TEXTURES)
           
    return {'FINISHED'}

Above is the import class that is called when the user selects to import the selected file type

def import_char(MODEL_DIR="", SKN_FILE="", SKL_FILE="", DDS_FILE="",
    CLEAR_SCENE=True, APPLY_WEIGHTS=True, APPLY_TEXTURE=True, IMPORT_TEXTURES=True):
'''Import a LoL Character
MODEL_DIR:  Base directory of the model you wish to import.
SKN_FILE:  .skn mesh file for the character
SKL_FILE:  .skl skeleton file for the character
DDS_FILE:  .dds texture file for the character
CLEAR_SCENE: remove existing meshes, armatures, surfaces, etc.
             before importing
APPLY_WEIGHTS:  Import bone weights from the mesh file
APPLY_TEXTURE:  Apply the skin texture

!!IMPORTANT!!:
If you're running this on a windows system make sure
to escape the backslashes in the model directory you give.

BAD:  c:\\path\\to\\model
GOOD: c:\\\\path\\\\to\\\\model
'''

if CLEAR_SCENE:
    for type in ['MESH', 'ARMATURE', 'LATTICE', 'CURVE', 'SURFACE']:
        bpy.ops.object.select_by_type(extend=False, type=type)
        bpy.ops.object.delete()

if SKN_FILE:
    SKN_FILEPATH=path.join(MODEL_DIR, SKN_FILE)
    sknHeader, materials, metaData, indices, vertices = lolMesh.importSKN(SKN_FILEPATH)
    lolMesh.buildMesh(SKN_FILEPATH,sknHeader, materials, metaData, indices, vertices)
    meshObj = bpy.data.objects['lolMesh']
    bpy.ops.object.select_all(action='DESELECT')
    meshObj.select_set(True)
    bpy.ops.transform.resize(value=(1,1,-1), constraint_axis=(False, False,
        True), orient_type='GLOBAL')

    #meshObj.name = 'lolMesh'
    #Presently io_scene_obj.load() does not import vertex normals, 
    #so do it ourselves
    #for id, vtx in enumerate(meshObj.data.vertices):
    #    vtx.normal = vertices[id]['normal']
    
if SKL_FILE:
    SKL_FILEPATH=path.join(MODEL_DIR, SKL_FILE)
    #sklHeader, boneDict = lolSkeleton.importSKL(SKL_FILEPATH)
    sklHeader, boneList, reorderedBoneList = lolSkeleton.importSKL(SKL_FILEPATH)
    lolSkeleton.buildSKL(boneList, sklHeader.version)
    armObj = bpy.data.objects['Armature']
    armObj.name ='lolArmature'
    armObj.data.display_type = 'STICK'
    armObj.data.show_axes = True
    armObj.show_in_front = True

if SKN_FILE and SKL_FILE and APPLY_WEIGHTS:
    if reorderedBoneList == []:
       lolMesh.addDefaultWeights(boneList, vertices, armObj, meshObj)
    else:
       print('Using reordered Bone List')
       lolMesh.addDefaultWeights(reorderedBoneList, vertices, armObj, meshObj)

if IMPORT_TEXTURES:
    pass
    
# # if DDS_FILE and APPLY_TEXTURE:
#     DDS_FILEPATH=path.join(MODEL_DIR, DDS_FILE)
#     try:  # in case user is already in object mode (ie, SKN and DDS but no SKL)
#         bpy.ops.object.mode_set(mode='OBJECT')
#     except RuntimeError:
#         pass
#     bpy.ops.object.select_all(action='DESELECT')


#     for mat in meshObj.data.materials:

#         Here I am trying to get the texture path of the image that should be selected
#         TEXTURE_PATH = ''

#         # ImportHelper

#         texImage = mat.node_tree.nodes['Image Texture']
#         try:
#             texImage.image = bpy.data.images.load(TEXTURE_PATH)
#         except RuntimeError as e:
#             print('Image not found or selected')
        

#         #img = bpy.data.images.load(DDS_FILEPATH)
#         #img.source = 'FILE'
#         #img.use_alpha = False   #BilbozZ
#         #matSlot.material.texture_slots[0].texture.image = img

Above is the called function that builds the mesh and it needs to apply the images to the respective materials

Any help with regards to importing would be appreciated, even completely alternative ideas

EDIT: I am able to create a list of image names(the names of each material) required, unfortunately the file names and the names do not match, so I need the user to select each the respective image file after being prompted the material name