For starters the Folder-selection dialog could be used if the images are all in one Folder.
var theFolder = Folder.selectDialog ("select folder");
And then the method getFiles could be used to get the files.
var theFiles1 = theFolder.getFiles("*_diffuse.jpg");
Loading the file as Layers can be done with the ScriptingListener code for File > Place for example and finding the corresponding mask files seems fairly easy.
Are they grayscale or RGB?
But why jpg anyway?
Are those renderings?
If so why not tiffs or some other non destructively compressed file format?
Placing the images may lead to resizing if receiving document and placed image have different resolutions.
To get the Layer Masks one could load the »…_mask.jpg« files in the same document or duplicate the document, convert it to a grayscale profile, turn off color management for the duplicate, fill it with black, place the mask there, then flatten, copy and then paste into a newly created Layer Mask in the original document. The positions should be identical if bot images are identical in dimensions and resolution.
Some of this would, again, need Action Manager code as one can record with ScriptingListener.plugin.
Another option for creating the layer mask would be to open the layer mask document then use apply image to transfer it to the other document's layer mask with either the invert check box selected or not, depending upon how layer mask file was created. Again, as c.pfaffenbichler mentioned, using scriptListener. You might want to even use apply image to create the diffuse layers in the target document. You could use c.pfaffenbichler's method for getting the files, but then create a new doc for your doc for your target document, create a new layer, then open your source doc and apply it to the new layer. In doing this, you could also at the same time create a variable for each layer to better track your layers for applying the layer mask to each.
Well, I don’t especially like copy/pasting in Scripts, either.
And as is so often the case in Photoshop there are more ways than one to achieve the result.