1
$\begingroup$

I've got a code that loads textures, and determines which is what with eNUM list of texture-type. Basically, I get the right textures connected to their right slots of the material (e.g. 29318291083.TGA goes to Normal). Now what I'm trying to do is rename them and export them out so the texture I just mentioned would come out as 29318291083_Normal.TGA.

I assume Blender isn't able to rename external files so I added a line that packs each texture when it loads it, so I can rename it while packed, then export as a new .TGA.

Now I got the texture's packed but I don't seem to find a way to rename a packed texture.

Any help would be very appreciated. Thanks!

$\endgroup$
0
$\begingroup$

Blender is able to do anything that you can do in python including renaming external files. I don't completely get what you are trying to do in detail, but you can rename textures in blender with

import bpy
bpy.data.textures['29318291083'].name = '29318291083_Normal'

In python you can rename a file with

import os
os.rename('a.txt', 'b.kml')

If your textures are stored similar to .obj and its .mtl (I didn't bother checking tbh) you can just use python to open the file, search for the right lines and rename them. As renaming files and editing text are very comming methods, Stackoverflow provides you with lots of help.

$\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.