Rename 100 Objects at Once with Five Lines of Blender Python

Duplicate a chair 100 times in Blender and the Outliner fills up with names like Chair610x666x1134.001, .002, .003 and on up to .099. That’s fine until you need to find one chair, export the scene to a game engine, or send the file to someone else. Renaming them by hand takes ages. I use five lines of Python instead, and it takes about a minute.

For this post I set up a hall of 100 chairs from my BlenderBlocks furniture sets, in Blender 4.5 LTS. Everything below was run in that file, so the screenshots show exactly what you’ll see.

Blender 4.5 Layout workspace with a hall of 100 identical chairs in Material Preview, and the Outliner listing names like Chair610x666x1134.001
100 chairs, 100 untidy names. Every duplicate gets the original name plus .001, .002 and so on.

The script

import bpy
prefix = "Chair_"
objects = sorted(bpy.context.selected_objects, key=lambda ob: ob.name)
for i, ob in enumerate(objects, start=1):
ob.name = f"{prefix}{i:03d}"

Here’s what each part does:

  1. import bpy gives the script access to Blender’s data.
  2. prefix is the new base name. Change it to whatever you need, like Table_ or Light_.
  3. The sorted(...) line collects every selected object and sorts it by its current name, so the new numbers follow the old order.
  4. enumerate(..., start=1) counts from 1 instead of 0.
  5. The last line sets each name with the number padded to three digits: Chair_001, Chair_002 and so on. The padding keeps them in order in the Outliner, so Chair_010 doesn’t land between Chair_001 and Chair_002.

How to run it

Don’t paste this into the Python Console. The console runs one line at a time, and the indented line inside the loop will trip it up. Use the Text Editor.

  1. Click the Scripting tab at the top of the window. You can also switch any editor to the Text Editor.
  2. Click New in the Text Editor header to make a blank text block. I named mine rename_selected.py.
  3. Paste the script in. Check that the last line is indented with four spaces.
  4. In the 3D Viewport, select the objects you want to rename. I pressed A to select all 100 chairs.
  5. Back in the Text Editor, choose Text > Run Script, or hover over the text and press Alt+P.
Blender 4.5 Scripting workspace with the five-line rename script in the Text Editor and all 100 chairs selected in the viewport
The script in the Text Editor, with all 100 chairs selected in the viewport.
The Text menu open in the Blender Text Editor, showing Run Script with the Alt P shortcut
Text > Run Script, or Alt+P with the mouse over the text.

The Outliner updates straight away. The Info editor at the bottom left of the Scripting workspace logs the run, and that’s also where any error shows up. If nothing happens, check that you actually had objects selected. If you get an error, it’s nearly always the indentation on the last line.

Blender Scripting workspace after running the script, with the Outliner listing Chair_001, Chair_002 and onwards and the Info editor showing bpy.ops.text.run_script
After the run: Chair_001 to Chair_100 in the Outliner, and the run logged in the Info editor.
Blender Layout workspace with Chair_001 selected in the hall of chairs and the Outliner showing the new sequential names
Back in Layout, the hall now reads Chair_001 to Chair_100.

Things to know

  • It renames objects, not their mesh data. Expand an object in the Outliner and you’ll see the mesh keeps its old name. Chair_001 still uses a mesh called Plane.053 here. That’s usually fine, but it’s worth knowing if you export by mesh name.
  • If a name you’re assigning already belongs to an object you didn’t select, Blender won’t allow two objects with the same name and adds .001 to the new one. Pick a prefix nothing else in the file uses.
  • Ctrl+Z undoes the whole rename in one step if you get it wrong.
  • The text block saves inside your .blend file. Next time, open it in the Text Editor, change the prefix and run it again.
Blender Outliner with Chair_001 expanded, showing its mesh data still named Plane.053
Chair_001 expanded: the object is renamed, the mesh data underneath is not.

What about Batch Rename?

Blender has a built-in Batch Rename under Edit > Batch Rename, or Ctrl+F2. It’s good for find-and-replace jobs, like swapping Chair for Stool across a selection. I still use the script when I want clean sequential numbers, because I can see exactly what it does and change it in seconds.

Blender Batch Rename popup opened with Ctrl+F2, showing Find/Replace options for selected objects
The built-in Batch Rename (Ctrl+F2). Handy for find and replace.

Five lines is a small script, but once you’ve watched 100 objects rename themselves, the next script feels a lot less intimidating.

Take it further

If you want to go from small scripts like this to building your own tools, my Python scripting in Blender course on Udemy builds up through practical projects.

Published by Thomas

With over 15 years designing in 3D applications Thomas has extensive knowledge necessary to help you become proficient in Blender