Find and replace sequence?

I got to correct many font files, in each one of them I have to do 7 Find and Replace procedures like:

Find “a” and change to “_a”
Find “b” and change to “_b”
Find “c” and change to “_c”

etc.

Well, 7 procedures for more than 100 fonts is a time consuming business…

Is there a way to define a kind of sequence that makes these 7 Find and Replace in one go?
I can dream of a script that will do that for whole fonts in a folder but I guess it’s a daydream!

That should be easy with a script, simply step through all open glyphs in all open fonts:

for font in Glyphs.fonts:
    for glyph in font.glyphs:
        glyph.name = ...

Then you probably do not need 7 find & replace iterations, but calculate the final glyph name right away.

Read the Python primers in the tutorials if you are not familiar with basic Python. Start here: https://glyphsapp.com/tutorials/scripting-glyphs-part-1

Thanks I 'll try that…

OK, looks like real magic. But for a non scripting guy like me, I quickly got lost…

What should be a script for changing in all open font files:
Find alef_ replace with alef
Find final_ replace with final

I would appreciate your help with this magic tool.

What I actually want is to replace in all open files:
alef_ gold with alefgold
final_ gold with finalgold

if glyph.name in ("alef_", "final_"):
    glyph.name = glyph.name.replace("_", "gold")