Newbie python quesion, batch renaming bone names.

Hi all

I’m trying to write a very short bit of python to take all the bones in an armature and alter their names slightly. Currently I’m using the convention “_L” and “_R” for left and right, but I’m trying to use Nathans mirror bone weights script and I believe it requires the convention “.L” and “.R”

I think what I’m trying to do is write a for loop that goes through each name and deletes the _R and replaces it with .R, but I’m really new to python and not sure how to go about that. Also if I manage this will that also update the names of any vertex groups that point to those bones, as if I had changed the bone name manually?

Can anyone help me out?

I think I’m making some progress, here’s what I have so far:

import bpy

bones_list = bpy.data.armatures['RIG_Name'].bones

for item in bones_list:
    bone_name = item.name
    bone_name.replace("_L",".L")
    bone_name.replace("_R",".R")
    
    

When I type this into the console, the output seems to indicate that the name has changed, but when I select that bone the name seems to be the same as it was before. :confused:

This works for me.

import bpy

bones_list = bpy.data.armatures['Armature'].bones

for item in bones_list:
	item.name=item.name.replace("_L",".L")
	item.name=item.name.replace("_R",".R")

Aha thanks!

I see now that I was wasn’t actually changing the name, just returning a string with the new name.