# Selecting objects by name starting with

I have many objects in the scene as they have been duplicated. pad, pad.001, pad.002 etc etc. I require a python code to select all of them by name.. name starting with 'pad' Thanks in advance.

The following snippet iterates through the objects in the scene and checks if their name matches a prefix. If it does it's added to the list.

objs = [obj for obj in bpy.context.scene.objects if obj.name.startswith("pad")]


If you want to select them, as in selecting them in the scene, then you can do the following for 2.7x:

for obj in bpy.context.scene.objects:
obj.select=True


For 2.8:

for obj in bpy.context.scene.objects:

bpy.ops.object.select_pattern(pattern="pad*")