Why script? If the images aren't too big, you can
1) is either File>Open as layers followed by ofn-layer-tiles (Layer>Tiles>Join tiles), or just ofn-tiles (File>Open tiles)
2) is either ofn-layer-tiles (Layer>Tiles>Split tiles ...) followed by ofn-export-layers (File>Export all layers), or ofn-tiles (File>Export tiles)
Second point, unless this is pixel art, smooth lines are rendered with pixels where the color is a mix of the colors on either side, so you may have more than 10 colors and you have to wonder what happens for these intermediate colors.
- load all the images as pieces of a single layer (sprite-sheet like),
- do the color change on the layer,
- split the layer back to files.
1) is either File>Open as layers followed by ofn-layer-tiles (Layer>Tiles>Join tiles), or just ofn-tiles (File>Open tiles)
2) is either ofn-layer-tiles (Layer>Tiles>Split tiles ...) followed by ofn-export-layers (File>Export all layers), or ofn-tiles (File>Export tiles)
Second point, unless this is pixel art, smooth lines are rendered with pixels where the color is a mix of the colors on either side, so you may have more than 10 colors and you have to wonder what happens for these intermediate colors.
- If you really have only 10 colors, then a simple way to do it is to make the image color-indexed and edit the colors in the palette (in which case you don't even need to create a work layer, the palette is the same for all layers).
- Otherwise the right way to do it is to convert the replaced color to transparency (bucket-fill with that color in Color erase mode) and then fill the transparent pixels with the target color by bucket-filling in Behind mode. This can be done quickly using the replace-foreground-by-background script.