10
$\begingroup$

Is there a way to batch rename objects in a sequence similar to: object1, object2, object3...? Where 'object' would be any custom name?

I found the batch rename datablocks script and it was really helpful for renaming a group of objects but gives a sequence like: object.001, object.002, object.003

Is there any way to use this script to give the first kind of sequence?

$\endgroup$
2
  • 3
    $\begingroup$ Does this help? $\endgroup$
    – p2or
    Jan 22 '17 at 20:14
  • 1
    $\begingroup$ Thanks poor! Looks like either that or the script below works well. Your link gives the option of connecting it with a hotkey which can be really nice too. $\endgroup$ Jan 23 '17 at 0:12
14
$\begingroup$

Blender 2.79

import bpy

for i, obj in enumerate(bpy.context.selected_objects, 1):
    bpy.context.scene.objects.active = obj
    obj.name = "object" + str(i)

Blender 2.8+

import bpy

for i, obj in enumerate(bpy.context.selected_objects, 1):
    bpy.context.view_layer.objects.active = obj
    obj.name = "object" + str(i)

Just replace "object" with "your name" and run this in the text editor (make sure you have all objects selected that you want renamed).

$\endgroup$
3
  • 2
    $\begingroup$ This didn't work for me when using Blender 2.8. changing line 4 to bpy.context.view_layer.objects.active = obj helped. update cheatsheet here => blenderartists.org/t/2-80-cheat-sheet-for-updating-add-ons/… $\endgroup$ Sep 28 '19 at 6:58
  • $\begingroup$ Answer edited with Furkan's comment ... Thanks man :) BTW - How to number like 01, 001 style? $\endgroup$
    – vklidu
    Jan 15 at 10:04
  • $\begingroup$ @vklidu What do you mean? You want to add leading zeroes all the time or you want to add a zero to each subsequent object in a sequence? $\endgroup$
    – JakeD
    2 days ago
6
$\begingroup$

Blender users can now do batch rename with (Menu: Edit ‣ Batch Rename and Hotkey: Ctrl+F2) without any add-ons. (blender +2.80)

enter image description here

An example: enter image description here

Read this blender manual section for more info: https://docs.blender.org/manual/en/dev/files/blend/rename.html#batch-rename

$\endgroup$
5
  • $\begingroup$ Yes, but there is not a way to add sequential numbering (if it is not hidden under "Regular Expression" :) $\endgroup$
    – vklidu
    Jan 24 '21 at 21:12
  • $\begingroup$ CTRL+F2 does not work since 2.90 apparently $\endgroup$
    – phil123
    Jan 13 at 11:01
  • $\begingroup$ @phil123 it did and it does for me. even on v3.0. I will add a screenshot just in case so anyone could find the short key if it does not work for them. $\endgroup$
    – Mobin
    Jan 14 at 19:54
  • $\begingroup$ @vklidu updated $\endgroup$
    – Mobin
    Jan 14 at 19:59
  • 1
    $\begingroup$ Nice trick :) so ... You have to do it in two steps. First to rename all objects with number ".001" included (this pushs blender's native numbering to renumber other objects sequently). Secondly use Find/Replace beginning and keep only number imgur.com/E9MUTNU (alternatively add suffix). Could you extend your edit, because OP was asking how to start name with sequential numbering ... especially point the trick here. Thank you $\endgroup$
    – vklidu
    Jan 15 at 9:47
5
$\begingroup$

I'm sure there are dozens of add-ons floating around that do this since they are quite easy to code and thus a good way to learn python, but here's mine:

https://github.com/gregzaal/batch-renamer

batch renamer screenshot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.