XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : how to distinguish directories(folders) and files in MEL?

11-22-2006, 09:49 PM
i am writing a mel script that involves "getFileList" command. it returns everything both folders and files with the given path. but now i need to know which ones are files and which ones are folders.

i kinda have a temp solution for this now, which i use "fileExtension" to check if it has an extension, if it does its a file, if not its a folder. this may work "ok" on NT system, but for linux/unix system, often files dont have extensions.

i would like to know how other ppl deal with this.

11-22-2006, 09:58 PM
never mind ppl, sorry
i think `file -q -type "path"` will do

11-23-2006, 06:45 AM
Just in case you do need it next time:

filetest -d "path/to/file/you/want/to/test";

If the object is a directory, 1 will be returned.

filetest -f "path/to/file/you/want/to/test";

If the object is a regular file, 1 will be returned.

11-23-2006, 07:11 AM
cool!! thanks isoparmB!!

CGTalk Moderation
11-23-2006, 07:11 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.