For simple cases there is no need for a script. Create an image container, load the images to be processed, set the output directory and input the new file name, e.g. "&filename;_mod.xisf" into the 'Output template' field.
Open PixelMath, input the expression. ($T is the placeholder for the currently processed image in the image container.)
Drag the blue triangle icon of the image container (New Image Container Instance) to the gray bar at the bottom of the PixelMath window.
Note that this will only succeed when the expression is the very same for all images in the image container. So there are limitations.
Bernd