ImageMagick 7 reads .xcf here, so without any paths.to.. or loops or variables and assuming a stack of same size / no offsets / transparent top & mid and a background .xcf for a single combined.png
Edit, just the bare bones to avoid a conversion to png which AFAIK is needed for IM 6 which does not support the Gimp 2.10
.xcf image format. Edit again, I see Ofnuts has a ps about that. Good script for the IM toolbox.
Code:
magick composite top.xcf mid.xcf temp.miff
magick composite temp.miff back.xcf combined.png
rm temp.miff
Edit, just the bare bones to avoid a conversion to png which AFAIK is needed for IM 6 which does not support the Gimp 2.10
.xcf image format. Edit again, I see Ofnuts has a ps about that. Good script for the IM toolbox.