How to rename selected objects except active object?
just check if it is the selected object and ignore it
import bpy

C = bpy.context
ao = C.object
for obj in C.selected_objects:
    if obj != ao:
        obj.name = &quot;SM_&quot;+ao.name