# How can I remove all uv layers but the last one and rename it on multiple objects?

I need to delete all UV's I have but the last one and change the name of the UV for every object selected to match. I can do it for the first but when it comes to repeating the process for all the objects selected I don't know.

• If you have to do this hundreds of times maybe it is a good idea to write a python script for that Jun 28 at 8:05

Use a python for that:

import bpy

for obj in bpy.context.selected_objects:
layers = obj.data.uv_layers
lastLayer = obj.data.uv_layers[len(obj.data.uv_layers) - 1]
for uv in layers:
if uv != lastLayer:
layers.remove(uv)
else:
uv.name = 'My UV name'

• Hey did you test this ? This throws an error because you're removing elements from a list you're iterating over Jun 28 at 16:41

Another method which worked for me because the other method didn't.

import bpy

for obj in bpy.context.selected_objects:
layers = obj.data.uv_layers
for i in range(len(layers) - 1):
layers.remove(layers[0])
layers[0].name = 'My UV name'