PDA

View Full Version : sourcing all scripts directly from network dir (?)


deadalvs
12-20-2007, 01:46 PM
hey !

to keep file handling as low as possible, i'd like to source mel scripts from outside the Userdocuments/maya/scripts/ folder.

how would i write a script that sources ALL SCRIPTS found in the directory directly from the correct folder on a network drive ?

example drive name: T:/MELSCRIPTS/

it's important that i don't want to update that script for each added script by typing:
"source script A, then B, ..."
but:
"source all You find"

any help ? thanks !

deadalvs
12-20-2007, 02:42 PM
hmmm...

the source command like this works:
source "C:/Documets and Settings/name/.../script.mel";

but the wildcard like this does not work:
source "C:/Documets and Settings/name/.../*.mel";


let's try some more...

deadalvs
12-20-2007, 03:54 PM
i got the script working...

will post it later ... or tomorrow...

:)

deadalvs
12-21-2007, 10:12 AM
okay there we go:

just enter the path there with "/" (forward slashs)
and put the code to a shell button or in the userSetup.mel file

/////

string $path = "enter path here";

string $FileArray[] = `getFileList -folder $path`;
for ($eachFile in $FileArray){
//print ($eachFile + "\n");
string $buffer[];
$numTokens = `tokenize $eachFile "." $buffer`;
if ($buffer[(size($buffer))-1] == "mel"){
string $FullPath = $path + $buffer[0] + ".mel";
eval ("source " + "\"" + $FullPath + "\"");
}
}

CGTalk Moderation
12-21-2007, 10:12 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.