PDA

View Full Version : Working with directories/files


frogspasm
04-29-2005, 06:41 PM
This example from Maya Help doesn't appear to work:

array $scripts = `getFileList -folder `internalVar -userScriptDir` -filespec "*.mel"`;
I also tried this with no luck:
string $script[] = `getFileList -folder `internalVar -userScriptDir` -filespec "*.mel"`;
If I use this line by itself I get a valid result as an array:
getFileList -folder `internalVar -userScriptDir` -filespec "*.mel";
Any ideas why this isn't working?

Thanks,

~Mike D.
mel noob

jadamburke
04-29-2005, 11:35 PM
the getFileList mel command requires the -folder string to END in with a slash like this "c:/winnt/syetem/"

"c:/winnt/system" won't work.

It took me a few stressful hours to figure that one out when I first encountered it.

strarup
04-29-2005, 11:46 PM
Hi Mike,

it's because you are calling/executing 2 commands... one command within the other... if you want to do something like that to reduce the lines of code instead of defining a string variable holding the folder name... you can use the Eval command...


string $daScripts[] =eval("getFileList -folder `internalVar -userScriptDir` -filespec \"*.mel\"");


otherwise you can use the text variable...

string $daFolder = `internalVar -userScriptDir`;
string $daScripts = `getFileList -folder $daFolder -filespec "*.mel"`;


however you can also put it into an one line function you can reuse in you scripts... e.g. like this... :)

global proc string[] daUserScripts()
{
return eval("getFileList -folder `internalVar -userScriptDir` -filespec \"*.mel\"");
}


and then in your scripts write it as follows...

string $daScripts[] = `daUserScripts`;


hope that helps... :)

regards

Alex

frogspasm
04-30-2005, 12:58 AM
Starup, that was the ticket.
I just finished my script. I'm rendering out a couple of hundred cars each with a different texture map. This is going to save me alot of time.

Thanks guys!

~Mike D.

CGTalk Moderation
04-30-2005, 12:58 AM
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.