List All Texture Files In Scene – Python Method

posted in: Uncategorized | 0

Here’s another Python snippet you can use in Maya to, in one line, gather a list of all the files referenced in your scene. This is of great use whenever you need to copy, export, or do other actions on textures associated with a particular Maya scene.

allFiles = [cmds.getAttr("%s.fileTextureName"%file) for file in"file")]

This Python list comprehension iterates over every file found using theĀ ls command and then gets the attribute that points to the file node’s texture path. Easy!


As an alternative, if you’re concerned about only transferring specific file types, or handling certain file types differently, you can use the following extended version of the above line.

fileFilter = ".jpg"
typedFiles = [cmds.getAttr("%s.fileTextureName"%file) for file in"file") if fileFilter in cmds.getAttr("%s.fileTextureName"%file)]

Leave a Reply