Thank you very much! The second way works great. I didnt get the first approach to work, but the second does well 🙂
Here is the script if someone needs it. It is probably messy I am not a programmer, but it does write the names of the selected materials into the texturname
import c4d from c4d import gui from c4d import storage import os #Welcome to the world of Python def changeTexture(shader): # shader ID texturePath = shader[c4d.BITMAPSHADER_FILENAME] # split aboslute path oldTexturename = os.path.split(texturePath) fileExtension = os.path.splitext(texturePath) # add prefix to newTexturename = matName + fileExtension[1] print (newTexturename) newTexturePath = os.path.join(oldTexturename[0], newTexturename) print (newTexturePath) # rename texture try : os.rename(texturePath, newTexturePath) print("Source path renamed to destination path successfully.") except OSError as error: print(error) # Assign the new value shader[c4d.BITMAPSHADER_FILENAME] = newTexturePath shader.Message(c4d.MSG_UPDATE) # Main function def main() : c4d.CallCommand(1029486) # Project Asset Inspector... c4d.CallCommand(1029816) # Select Assets of Active Elements c4d.CallCommand(1029820) # Globalize Filenames # Iterate over selected material material = doc.GetFirstMaterial() if not material: return while material: if material.GetBit(c4d.BIT_ACTIVE): shader = material.GetFirstShader() global matName matName = material.GetName() while shader: # Test if the current node is a bitmap shader. if shader.CheckType(c4d.Xbitmap) : changeTexture(shader) shader (shader.GetDown()) shader = shader.GetNext() material = material.GetNext() c4d.CallCommand(200000273) # Reload All Textures # Execute main() if __name__=='__main__': main()