How to get the source image path when texnode.image.name is different from it?

Imported fbx all have textures named in a different convention such as ‘Map #12’ or ‘Image.xxx’. texnode.image.filepath() outputs empty instead of the actual texture image path, although when you click the ‘Open Image’ button of the tex node, you can see it points to the correct image.jpg. And there’re lots of ‘Map #xx’ texture nodes that don’t point to any real images.

Is there a way to get the real texture path and get rid of the fake textures?

You can try using file -> external data -> find missing files first. After that you could get rid of any image with empty file path and has # in the naming. Or just refactor your code above and do a recursive search in your folders and overwrite the paths.

Unfortunately the FBX importer sometimes brings or creates those fake images (with # in the name) during the import stage that becomes an issue down the production.

The thing is, some # have real textures, and some don’t. There’s no way to tell because texnode.image.filepath or texnode.image.filepath_raw both get empty image file path even when real textures are linked.

You can probably check the image data to see if it is really empty or not. I do not have that kind of image in a .blend file atm so I can’t test it myself.

Probably faster jsut looping over bpy.data.images instead doing that big for loop over meshes and materials. You could add the filename for the name, but you can run into issues have name which its quite long. you can check if the filepath exists, if not skip it