View Full Version : getFileList not handling variable for flag


ellis3d
08 August 2008, 03:22 AM
I am working on the file managment part of my script but I am having trouble with the -filespec flag not accepting a string variable, if I explicitly use an extension e.g. "*.jpg", it works like it should, but I am trying to use the file the user 1st selects through fileDialog to both snag the path and its extension. The extension will then be used to filter out the junk files (thumbs.db, OSX leftover files, etc). I can only think that perhaps the wildcard may need some kind of formating like quote marks do.

====================CODE=====================
string $firstImage = `fileDialog`; // User selects 1st image in sequence
string $imageDir = (dirname ($firstImage) + "/"); // Slash must be added
string $fileType = ( "\"" + "*." + `fileExtension($firstImage)` + "\""); // Format the file type to "*.ext" format
// string $fileList[] = `getFileList -folder $imageDir -filespec "*.jpg"`; //This works
string $fileList[] = `getFileList -folder $imageDir -filespec $fileType`; //This doesn't

for( $file in $fileList )
{
print ("-" + $file + "\n");
}
print ("\n" + "File Type = " + $fileType + "\n");
print ("Directory = " + $imageDir + "\n");
print ("Total Files = " + `size $fileList` + "\n");

digitalandrew
08 August 2008, 11:03 AM
Hi. You dont need to put the quotes around the file type variable... mel knows that it's a string by the way it's been defined...


string $fileType = ("*." + ` fileExtension($firstImage)`);


You only need it when you manually specify a string... as you have demonstrated with both working and not working lines you have tried.

:cool:

-a

ellis3d
08 August 2008, 05:30 PM
Thanks Andrew! Works like charm.

-C

CGTalk Moderation
08 August 2008, 05:30 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.


1