# Bulk renaming armature bones after already creating them?

I'm trying to create an animation rig with quite a few armature bones. I'm modeling a bug, which has a total of 14 legs, and each one of those legs has 5 armature bones. The legs are identical, except they are in different positions with different rotations, so to set up the armatures I simply created an armature for one leg and duplicated it to the other legs, rotating and repositioning it as needed. However, I named the front legs FrontLeg.L and FrontLeg.R. The other legs, since they're just duplicated, are, for example, FrontLeg.R.007, etc etc. I can easily rename the parent bone for each leg, but this becomes tedious very quickly to do this for all of the children as well.

Is there any easy way for me to rename the parent bone to, for example, 2ndFrontLeg.L and have all of the children automatically be assigned names 2ndFrontLeg.L.001, 2ndFrontLeg.L.002, etc, after they've already been created? I'm completely ok with using addons as well

• I would simplify your model a bit (animating 4 legs is difficult enough, maybe 6 or 8 is reasonable if you have a bug or a spider but 14?) leaving less bones to name and then you could use the flip names option which flips names of half of your bones. But that does not answer your question. – aky-her Oct 20 '15 at 5:49

1. Open a text editor in Blender and paste the code below there.
2. Replace the text in "original" and "replacement" as needed.
3. Go to pose mode and select the parent of the new chain.
4. Press "Run Script" in the text editor.

Here's the code:

import bpy
original    = "FrontLeg"    # Original name that was duplicated to generate all legs
replacement = "2ndFrontLeg" # The new name you want for this particular leg's bone chain

parent = bpy.context.active_pose_bone
for b in [ parent ] + parent.children_recursive:
b.name = replacement

• Looks great! However, there's one small change to it that I would like: could you make it automatically change the number (e.g: .007) at the end of the name of each bone? So that it's like: 2ndFrontLeg.L.001, 2ndFrontLeg.L.002, etc instead of just keeping the digits, which often ends up with things like: 2ndFrontLeg.L.004, 2ndFrontLeg.002, etc etc, not in order – markasoftware Oct 20 '15 at 23:06
• @Markasoftware, updated the script to work as requested. – TLousky Oct 21 '15 at 5:50
• I think your original answer would have been more useful in my test case. How would you simply do a find and replace in all bones? @TLousky – Tyler Mar 20 at 5:47
• You could always try to: for b in [ parent ] + parent.children_recursive: b.name = b.name.replace('something','somethingelse')` – TLousky Mar 20 at 18:14