How to remove a common prefix from vertex-group names? I'm looking to write a script that can remove a prefix from all vertex group names, so that I can use the mirror modifier appropriately. The models I work with have "b_" as a prefix for most group names. I found this script to add the prefix back on after mirroring, but it still takes far too long to process the whole thing.

Updated: Removes &amp; Adds prefix back in

import bpy
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode='OBJECT',toggle=True)
for g in obj.vertex_groups:
    if g.name.startswith('b_'):
    print(g.name)
    g.name = g.name[2:]

else:
    print(g.name)
    g.name = 'b_' + g.name
To remove the "b_" prefix

import bpy
obj = bpy.context.active_object
prefixes = ["b_", "f_", "h_", "x_"]

bpy.ops.object.mode_set(mode='OBJECT',toggle=True)
for g in obj.vertex_groups:
    for prefix in prefixes:
        if g.name.startswith(prefix):
            g.name = g.name[2:]