File Handling in MEL – Part2


Problem:
To perform a set of file operations including creation, deletion and listing of files and directories
Solution:

Creating  folders using sysFile command

 sysFile -makeDir "/home/user/mayaFolder"; //unix
 sysFile -makeDir "C:/Documents and Settings/MayaFolder"; //windows
 

Get the list of mel scripts in the  maya scripts directory

 getFileList -folder "/home/user/maya/scripts" -filespec "*.mel";
 

Stripping a file path in to directory name and base name.

 $filePath = "/home/user/maya/2011-x64/scripts/userSetup.mel";
 $dirName = dirname($filePath);
 $baseName = basename($filePath , "/");
 

Commands:
sysFile, dirname, basename
Discussion:
The sysFile command can be used to create, delete or rename files and directories from within Maya. The dirname and basename commands can be used to strip a file path in to the absolute path and filename. Using a combination of these three commands its possible to perform a variety of OS level operations from within the Maya workspace itself.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s