[Closed] escape characters in file paths
Hi all,
I have to read max file paths and process them. The problem is that I can solve it by adding the “@” character in front of my path, but I cant do this if I have the paths stored in an array, or in other words add “@” to a variable. So say for example, I have to open a bunch of max files and perform some operations on them . :
myFiles = #("d:\art\rigs\gun.max","d:\art\rigs\lamp.max")
for i=1 to myFiles.count do
(
-- load myFiles[i] and perform operations
)
With the “\r” acting as an escape character, I can’t load my files. Thanks for the help,
Cheers,
Vikram.
I didn’t exactly understand why you can’t use @, but assuming you really can’t, you can use:
for i = 1 to myfiles.count do
(
local fName = substituteString myFiles[i] "\\" "\\\\"
-- do your thing on fName
)
Or / instead of , from the Maxscript Help > String Literals
File Path Name Strings
File path name strings use the backslash character to separate a parent directory from its sub-directory. The backslash is used as an escape character, therefore file path names specified in a string should use the escape character sequence for a single “” character, i.e., “\”, or specify the string as verbatim using the @ character introduced in 3ds Max 2008 (see further on this page)
…
For strings that are used as file names or paths, the “/” character can be used instead of the “\”. MAXScript internally interprets the “/” character as a “” character when used in a file path name string.
…
Verbatim String Literals
Verbatim string literals added to MAXScript in 3ds Max 2008 are prefixed by the ‘@’ character and are NOT expanded even if containing backslash escape character sequences like ’ ‘, ’
’ or ‘\r’.
…
-Eric
EDIT: You should be able to use Verbatim String by simply modifying each path in the array.
myFiles = #([b]@[/b]"d:\art\rigs\gun.max",[b]@[/b]"d:\art\rigs\lamp.max")