I used this in a recent project. Obviously you’ll need to adjust it for your armatures, but it’ll get you most of the way there.
import bpy
def constraintBoneTargets(armature = 'ROOT_JNT_SKL', rig = 'rig'):
rigobj = bpy.data.objects[armature]
for ob in bpy.context.scene.objects: ob.select_set(False)
bpy.context.view_layer.objects.active = rigobj
bpy.ops.object.mode_set(mode='POSE')
bpy.ops.pose.select_all(action='SELECT')
for bone in bpy.context.selected_pose_bones:
for c in bone.constraints:
bone.constraints.remove( c )
if bpy.context.scene.objects[rig].data.bones.get("ORG-"+bone.name) is not None:
constraint = bone.constraints.new('COPY_TRANSFORMS')
constraint.target = bpy.context.scene.objects[rig]
constraint.subtarget = "ORG-"+bone.name
constraintBoneTargets()
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_pattern(pattern='rig')