View Full Version : MEL Script to replace a file name

10 October 2010, 06:58 PM
Hey guys,

I'm working with a render farm at school, and one of the things it requires is that all the file textures in a maya scene be set to a relative path instead of an absolute one. I'm trying to work up a little MEL script that will do that for me, so I'm not going through scenes and re-naming dozens of file paths...but I can't get it to work correctly.

Here's what I have so far:

global proc string filepart( string $path )

string $filepart = match( "[^/\\]*$", $path );

return $filepart;

string $fullpath = `getAttr file1.fileTextureName`;
string $file = filepart( $fullpath );
setAttr -type "string" file1.fileTextureName ("sourceimages/" + $file);

I think the problem lies somewhere in the $path variable. If I change the setAttr string to just text, for instance if I specifically type in the file path name (e.g. "sourceimages/file1.jpg") it changes the name just fine. But once I have the ("sourceimages/" + $file) it craps out on me. Anyone know what I'm doing wrong here?



10 October 2010, 07:12 PM
I feel like an idiot...I've been trying to re-code this for at least an hour, and I suddenly realized I hadn't actually copied my texture file into the sourceimages folder so that Maya had something to change the original file path to. Problem solved!

CGTalk Moderation
10 October 2010, 07:12 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.