The following code shows how to extract the names of images that were put in a stack to display on the image or to report in measurement results.

In this specific example, multichannel images were put into a stack and then the channels split such that the images have channel information in front of the file name and a series number at the end. The string parsing cuts these off.
substring(label, dash, lengthOf(label)-15);
Similarly, a function that returns the file name without the extension could be called.

More description of the command getMetadata() at https://imagej.nih.gov/ij/developer/macro/functions.html.

In this example, it would probably be useful to also add a scalebar to all images.

macro "Stamp metadata on stack" {
  textSize = 72;
  run("Colors...", "foreground=white background=black selection=yellow");
  setFont("SansSerif",   textSize);
  run("Select None");
  for (s=1; s<=nSlices; s++) {
    setSlice(s);
    label = getMetadata("Label");
    dash = indexOf(label, "-") + 2;
    label = substring(label, dash, lengthOf(label)-15);  // removes channel from beginning and "series" from end
    // print("" + s + " \t[" + label +"]");
    drawString(label, 4,  textSize+2);
  }
}