View Full Version : system command with spaces in dir's

09 September 2005, 10:14 PM
I'm trying to call a external image converter (texconv.exe, part of the directX sdk) from our network scripts folder which is ;

Z:\Project\Art Assets\Tools\MEL_Scripts\ddsconverter

The file I'm trying to convert is also on our network in a similar place;

Z:\Project\Art Assets\3D Projects\- Rome Textures -

As you can see both dir's have spaces in them, which I belive is part of my problem.

I can't get this to work at all. If I open a command line I can do it by putting both file names in "'s, e.g.

"Z:\CityBuilder\Art Assets\Tools\MEL_Scripts\ddsconverter\texconv" -ft bmp "Z:/CityBuilder/Art Assets/3D Projects/- Rome Textures -/"

The -ft flag is filetype by the way, I'm trying to convert a DSS to a BMP (or anything that Mental ray will render). This works in a command line, but the same thing in MEL does not. e.g.

string $FileName = `getAttr ($EachFile + ".fileTextureName")`;
string $DDSConvert = ("\"Z:\\CityBuilder\\Art Assets\\Tools\\MEL_Scripts\\ddsconverter\\texconv\" -ft bmp \"" + $FileName + "\"");

print ("\n SYS command = " + $DDSConvert);

Sys retrun = 'Z:\CityBuilder\Art' is not recognized as an internal or external command, operable program or batch file.

Can anyone see what's up? and no I didn't create the original dir structure and it's way too late to change it now.

Or if anyone knows a good way to get arround Mental ray not rendering DDS files, that would also help as that is what I'm trying to do. Basically at render time my script checks the renderer and if it's mental ray it converts any DDS files to BMP's so that mental ray will work. After the render it switches them back again so the artits has no idea their dds files didn't get rendered. Thats the plan anyway.



09 September 2005, 09:18 PM
I've had this problem too. The flag after the exectuable seems to cause the problem. Anyways, a workaround is using a batch file.

try this, create a batch text file:

//contents of texconvBat.bat:
"Z:\\CityBuilder\\Art Assets\\Tools\\MEL_Scripts\\ddsconverter\\texconv\" -ft bmp <file_name>

then in mel:
string $batFile = "C:/texconvBat.bat"; // file path to batch file

Of course, you'll have to put the <file_name> into the bat file yourself. And if the file name is dynamic, you may need to do some I/O to write to file the contents of the bat file.

hope this helps,

09 September 2005, 02:57 PM
Thanks for the reply, this sounds like a good solution. As a temporary fix I moved the exe file to the local drive leaving only 1 filename with spaces which works, but it means I can't update the program without getting all the artists to update manually. I will try your solution latter today.



CGTalk Moderation
09 September 2005, 02:57 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.