I am an experienced Maya user but fairly new to programming and there is something I am trying to figure out. I am attempting to create a function for use inside of Maya that would allow me to search the file structure for a texture file.
What I want it to do is this:
if texture_name is missing:
access folder containing this scene
go up one file to character folder
if textures folder exists:
if object matching texture_name exists:
set this folder as new texture path
alternatively it could do something like this:
texture path is A:B/C/D/texture_name
if A:B/C/D/texture_name == False:
if A:B/C/E/texture_name == False:
if A:B/F/E/texture_name == False:
etc. replacing the texture path one layer at a time until it works
EDIT: I have found a workaround that generates the texture paths I need, but I am still looking for a way to Query whether a certain file exists. Like the objExists function but to check for files outside the maya scene.
You can use the os module to check if it exists. There is os.path, os.path.isfile()
extracting only texture filenames being used in maya file from the list of filename paths