View Full Version : Syntax help needed - using " in maxscript

06 June 2008, 06:47 AM
I have a automatic system for producing a lot of similar single object renders of my scene containing 200+ objects. I want the output renders filename to be the same af the objectname in max and therefore I have programmed maxscript to create a batch file that rename all of the renders... but one little thing is missing. The syntax in good old dos for renaming files dosn't allow any spaces except for the one seperating the two filenames and all my object are called: 'something - like - 5555.555' so that is no good. But when include one " at each end of the statement the rename completes flawless.
is there any way that you can add " in maxscript? If do this: outputstring= """+name+" - "+number+""" if of cource fails. Is there a solution?

If not is it posible to trim all spaces in my outputstring?


06 June 2008, 11:13 AM
outputstring= """+name+" - "+number+""" if of cource fails.

you need to escape your quotes :)

outputstring= "\""+name+" - "+number+"\""

However.. instead of renaming the render when done, why not change the value of 'rendOutputFilename' so that it will render to the correct filename directly? (presuming you perform one render per object, rather than an animation which somehow goes from object to object).

If not is it posible to trim all spaces in my outputstring?
With a custom function, easily. You want to replace all, I think, rather than trim (which tends to be left / right only, and not any spaces in the middle).

fn strFindAndReplaceAll str f r = (
local pos; local fcount = f.count
while ((pos = findString str f) != undefined) do (
str = replace str pos fCount r
strFindAndReplaceAll "hello world of wonders" " " "|"

06 June 2008, 11:20 AM
If you're using max 2008 or higher (or have the AVG extension ( installed), you can also use the following to replace strings:

substituteString <source_string> <from_string> <to_string>


CGTalk Moderation
06 June 2008, 11:20 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.