I hope that's what you're looking for.
Select the low-poly object and run the script to add a <Name>_LowPoly suffix to the objects name in the first place, join all other mesh objects of the collection and rename the result to <Name>_HighPoly:
import bpy
suffix = "_LowPoly"
act_obj = bpy.context.view_layer.objects.active
Append the suffix to the active object
if suffix not in act_obj.name:
act_obj.name = act_obj.name + suffix
Get the collection of the active object
obj_coll = act_obj.users_collection[0]
Create an empty list
high_poly_objects = []
Append all mesh objects (of the collection) to the list
for ob in obj_coll.objects:
if not "Low" in ob.name and ob.type == 'MESH':
high_poly_objects.append(ob)
Deselect all objects
bpy.ops.object.select_all(action='DESELECT')
Select all High-Poly objects to call the join operator
for ob in high_poly_objects:
ob.select_set(True)
bpy.context.view_layer.objects.active = ob
Join all objects selected before
bpy.ops.object.join()
Get the object in context and re-name it
if "High" not in bpy.context.object.name:
bpy.context.object.name += "_HighPoly"
Optional -> Invert the selection for fun
for ob in obj_coll.objects:
if "Low" in ob.name:
bpy.context.view_layer.objects.active = ob
ob.select_set(True)
else:
ob.select_set(False)
You can also override the context of bpy.ops.object.join() to avoid any viewport selection changes. Select all objects, make the low-poly object the 'Active Object' and run the script:
import bpy
hp_suffix = "HIPOLY"
lp_suffix = "LOWPOLY"
C = bpy.context
scene = C.scene
ob_active = C.active_object
if not ob_active.name.endswith(lp_suffix):
ob_active.name += "_{}".format(lp_suffix)
obs = []
for ob in C.selected_editable_objects:
if ob.type == 'MESH' and ob != ob_active:
obs.append(ob)
if len(obs) > 1:
c = {}
c["object"] = c["active_object"] = obs[0]
c["selected_objects"] = c["selected_editable_objects"] = obs
# Blender 3.2+
with C.temp_override(c):
bpy.ops.object.join()
# Blender 2.8+
#bpy.ops.object.join(c)
if not obs[0].name.endswith(hp_suffix):
obs[0].name += "_{}".format(hp_suffix)