Batch Renamer

batch_rename_screenshot2

batch_rename_screenshot

[Download]

I’ve had this one for a while now, but it’s been a mess of slightly working code until recently – but now I like to think it’s unbreakable! (yes, that’s a challenge)

It’s a simple renaming tool meant for a bunch of similar objects. All it will do is rename them to something consistent with incrementing numbers (name_01, name_02, name_03…)

You have control over the starting number and the sorting of the objects, and that’s about all you need really. I have considered doing something more complicated with bones and left/right versions and whatever, but I seldom need such a thing anyway.

Here’s an explanation of each item in the interface:

separator

Get base-name: (first icon-button at the top left) Sets the base-name to that of the active object (stripping it of any numbering it already has)

Base-name: What to name the objects as (base_name_01, base_name_02….)

Rename: The big button to do the renaming

Advanced: Show all the options and controls

Separator: How to separate the base name and the numbers (name_01, name.01, name-01 or any separator of your choice, doesn’t have to be a single letter)

Padding: The number of digits in the numbering, adding trailing zeros to fill the space (name_01, name_001 or name_0001…) – Auto mode will figure out how many objects are selected and thus how much padding is needed. Manual mode will allow you to choose how much padding you want, but will increase it automatically if it’s not enough. None mode will not add any trailing zeroes.

Start Number: Begin naming the objects with number starting from here.

Continued Numbering: (ellipse icon just to the right of the start number) Increase the start number every time you rename objects such that you can carry on numbering from where you left off last. I suggest you use Manual padding for this one, since if the total number of objects renamed goes above the next level of padding (above 100 for example) then there will be inconsistent padding (name_05, name_89, name_134 – different amount of digits)

Sorting: How to sort the objects, by location, scale or dimensions. Dimensions is useful to use as a “visual” scale – think 1000 rocks of different sizes but all with 1.0 scaling.

Sorting Axis: In which direction to sort them – on one of the axes or on the average of them (‘All’)?

Reverse: Flip the order of the sorting, E.g: go right-to-left instead of left-to-right

separator

And that’s it!

Please rip it to shreds. Find any bugs, suggest any features. And if you feel like it, I’d appreciate a code-review too.

  • Will be great if we can start counting from 0 instead of 1. (cube00, cube01, cube02…)
    Also adding sufix to names will be usefull. (cube05_collision, cube05_gfx)

  • Nice one! This is handy. And Bartek have good points. Thanks.

  • I have tested out this now. Works great. But I think there really should be option to rename “Mesh” too, now it renames only object datablock. This is important for systematic person :)

  • Pingback: Add — On’s / Batch Renamer()

    • logiquefloue

      Thank you god, someone has done this. Very useful this addon, thank you very much. This will save a lot of time to all those like me who work with very large number of objects. Before I manually rename my objects according to location x or y or z .
       The addon does not work when objects come from a separation (bpy.ops.mesh.separate) :( why?

      • Glad it helps!

        What do you mean it doesn’t work? Works just fine here. Remember that it uses the object location (the origin/pivot) – so if you separate the pieces without moving the origin afterwards (Ctrl+Alt+Shift+C in object mode), all the origins will be in the same place and therefore have the same location and no logical order to rename from.

        • logiquefloue

          hello,
          I was so happy with this addon I’ve completely forgotten the origins. I am very sorry.
          it works very well.
          thank you

  • I get this error:

    Traceback (most recent call last):
    File “/Applications/Blender/blender.app/Contents/MacOS/../Resources/2.72/scripts/modules/addon_utils.py”, line 299, in enable
    mod = __import__(module_name)
    File “/Users/student/Library/Application Support/Blender/2.72/scripts/addons/batch_rename.py”, line 15, in
    from math import ceil, loglog10
    ImportError: cannot import name ‘loglog10’

    Blender 2.72 OS X

    • I genuinely have no idea how that slipped in there, or worse, how long it’s been there O_O

      Thanks for letting me know :)

  • TARDIS Maker

    Got an error :(
    Blacked out bit’s are just my name.

    Are you still maintaining this?

    • TARDIS Maker

      I got it to work. The issue was that I accidentally had an empty selected.

      But, still an error.

  • Pingback: Sélection d’addons Blender Partie 3: Community()