Unpacking a variable in a filename in Maya

I am working with a scene that is making use of a variable name in the file paths. When running my python code, I am not aware of what the variables will be before I hit them. It looks similar to this…$stupidFilePath\scenes\myfile.tga. When I run a processes in Maya manually like “Convert To File Texture”, Maya knows how to read and deal with this path. However, when I run it with code using “pm.convertSolidTx”, it fails and never seems to work. I am at a loss as to what to do to resolve the path into a full proper path then run my code.

Any ideas?

Morris

Try this:

import os
resolved_path = os.path.expandvars('$stupidFile/scenes/myfile.tga')

Zuko just beat you to the same thing…ha ha