Problem description

I've got a simple script in Text Editor

enter image description here

And want to get the function defined in it be able to execute from Python Console.
Old Blender Cookie tutorial says that all I have to do is write in console:

>>> from rename import BatchRename
>>> BatchRename('Monkey')

But I've got a Traceback message enter image description here

I looked through a lot of artitcles but only this one was helpfull.
And the only way I could refer to this script from console and execute the BatchRename function was

>>> filepath = bpy.path.abspath("//rename.py")
>>> exec(compile(open(filepath).read(), filepath, 'exec'))


Why the first script doesn't work?
What is the best working method to refer to Script from the Text Editor From Python Console?

  • $\begingroup$ Does this answer your question? $\endgroup$
    – Jakemoyo
    Commented Aug 2, 2022 at 17:23
  • $\begingroup$ you need to install the BatchRename module. you can install it with pip package manager. but i don't know what the corresponding package name is that includes the module batchrename. let me know what it is and i can continue teach how to run your script. $\endgroup$
    – Harry McKenzie
    Commented Aug 3, 2022 at 11:07
  • $\begingroup$ I posted a question on ubuntu: askubuntu.com/questions/1421766/… $\endgroup$
    – Harry McKenzie
    Commented Aug 3, 2022 at 11:40

1 Answer 1


This isn't an answer to the scripting side of your question, but if you're looking to batch rename things in your file, there already exists a function for that.

It's called Batch Rename and it can be found in the Edit Menu. You can also call it with Ctrl + F2

enter image description here

It has several features to allow you to fine tweak the object names. You can also set it to discriminately rename only objects or only bones, etc.

Hope that helps.

  • $\begingroup$ Thanks for the reply, I appreciate that, but I've already known about this feature. The main idia here is to make Python Console refer to functions from text editor =) $\endgroup$
    – Yuri Titko
    Commented Aug 3, 2022 at 7:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .