Rename all textures on model


Hi. How can I rename all the textures on my model? (ex. image_1; image_2…) I did that with a script if I remember well… But I don’t remember that. Someone knows the solution? Thanks!


First collect all of the models materials:


Now step through and rename them thus:

mats.each{|mat|;! }

However, if you mean the actual image files associated with a texture which is attached to a material, then it’s more convoluted, you need to filter the materials for those with textures, then save the texture file renamed [JPG or PNG] to some folder [perhaps in TEMP or with the model ?], and then immediately reassign that renamed file with the texture…

dir=Sketchup.temp_dir # or perhaps =Sketchup.active_model.path.dirname
Sketchup.active_model.materials.find_all{|m| m.texture }.each{|material|
  # keep file type, or perhaps =".png"
  puts basename=rename+extname! # increment rename by one digit
  filename=File.join(dir, basename)

This sorts the model’s textured materials files in the order they were added to the model.


Thank a lot. I meant the first option


Thanks for the tips TIG !


TIG thanks a alot for this tip. But it is erasing the materials UVs. So is it possible to keep the same UV data and collect the textures with new name in a folder?