Processing batches of images

precondition: You have -input n images. For sake of discussion, let image variance iv==0 be the “certain condition” that distinguishes the images that partition your image list into separate groups. An image with no variance at all among constituent pixels is likely a black image. Perhaps these are your third and seventh images mentioned In your preamble. See Mathematical expressions for the various per-image metrics that G’MIC maintains. Familiarize yourself with the name command; it is the principle means to gather together images into various groups or “collections”; all images in a particular group have a common name — and perhaps a common condition, if the scriptwriter arranges this as so. Then something like:

groupid=0
foreach {
   if iv==0
      groupid+=1
   fi
   name. "Group_"$groupid
}

That is, whenever an image with the distinguishing characteristic is noticed in the image stream, it advances the groupid count. The image with the distinguishing characteristic is the first to be enrolled in the new group. That image, and all others up to (but not including) the next image with the distinguishing characteristic, are enrolled in this group. One use case for this could be the frames of a video, with all the scenes separated by blank “sentry images.”

Often what we loosely term as “naming images” is more closely modeled as putting a single image in a named group. Usually, the loose terminology is harmless, but can lead to soft mental bugs.

Haven’t tested the proposed code and it is time to walk the puppy dog. Good luck!