Edit multiple anchors names

I have multiple glyphs with anchors. One glyph with anchor name _Topleft_1 Second glyph with anchor name _Topleft_2 third with anchor name _Topleft_3, and so on… I need to delete the _# at the end so in all the glyphs I will have only same anchor “_Topleft”. Anyone can share a script for that? Thanks a lot!

You can find a script “Find and Replace in Anchor Names” in the mekkablue scripts (available in the plugin manager). Select multiple glyphs at once to batch-process glyphs.

Thanks! True. But… I need to change many anchors in many glyphs at once… With the script, I need to do it one by one… Because the anchors are having different names at the end…

If I could find the _ and any number after that, and delete it from all the anchors, it will do the work.

Select multiple glyphs at once and run the following code:

for selection in Font.selectedLayers:
	parent = selection.parent
	for layer in parent.layers:
		for anchor in layer.anchors:
			particles = anchor.name.split("_")
			if len(particles) and particles[-1].isnumeric:
				anchor.name = "_".join(particles[:-1])
1 Like

Genius! Thank you so much!! Works perfectly! Thank you, Sebastian.

No problem :slightly_smiling_face: This is a great example of how easily you can automate things in Glyphs. I highly recommend checking out the scripting tutorials: Scripting Glyphs, part 1 | Glyphs

The time you will be able to save by just writing a few lines of very simple Python is immeasurable. It might be a daunting prospect to learn programming, but I assure you, it’s nowhere near as complicated as it may seem!

1 Like

Thank you, Sebastian. I truly appreciate it. I’ll give it a try :slight_smile:

Enjoy. And don’t hesitate at all to ask any questions (however basic they may seem) in the forum.

1 Like

Thanks a lot! I asked another question about the color of the glyphs… Do you know if there are ways to color the glyphs in colors other than the default? I have many kinds of glyphs and need to organize them better for my eyes :slight_smile: