The following methods provide access to external files and directories.
Returns an array of file names that match the given wild-card path name.
FOR EXAMPLE, |
The following code gets an array of all the .max scene files in c:\foo and then loops over the array, opening each file and printing the objects in each: |
getFiles() can also be used to determine if a file or file pattern exists.
See also doesFileExist() which checks for a single file only and does not supportwildcardpatterns.
Returns an array of directory paths that match the given wild-card directory path name.
Creates a new directory with the given name.
Returns true if the path was created successfully or if it existed already.
Returns false if the path could not be created either because the argument was not a valid path or due to insufficient writing rights.
If the optional all: keyword argument is set to true (default since 3ds Max 9, in 3ds Max 8 the default was false ), all sub-directory levels specified in the path will be created if they do not exist.
MAXScript does not provide a method for deleting directories. See the last example for HiddenDOSCommand() for a possible workaround.
Fails if the file is open in MAXScript.An open file can be closed using the respective close() method for ASCII or Binary streams, or if the handle is not accessible due to local scope, by calling manual Garbage Collection using gc().
Does not work on directories created using makeDir() , only on actual files. For a way to delete a directory, see the last example for HiddenDOSCommand().
Returns true on success, false on failure.
Renames the old file to the new file.
This can also be used to move a file between directories.
Fails if the new file already exists or if the old file is open in MAXScript.
Returns true on success, false on failure.
Copies the existing file to the new file.
Fails if the existing file is open in MAXScript, the target file cannot be created, or the target file already exists. In the latter case, you can use deleteFile() to remove the existing target file first.
Returns true on success, false on failure.
Returns the size of the specified file in bytes.
Returns 0 if the file could not be found.
getFileAttribute <filename_string> <attribute> setFileAttribute <filename_string> <attribute> <boolean>
Get and set the attributes associated with a file.
The get function returns true or false depending on the state of the specified attribute.
The set function sets the state of the individual attribute specified (leaving other attributes as they were).
The valid <attribute> values are:
Returns a String value containing the modification date for the specified file, for example "1/29/99 1:52:05 PM" .
Returns a String value containing the creation date for the specified file.
Returns the file and product version for the specified file, or unknown if this data is not specified in the file. This data is typically specified only for executable and application extension (i.e., .dll) files.
Returns true if the specified file exists and the specified security attribute is set, where <attribute> is one of #read , #write , #execute , #all .
If <file_name> is a directory and <attribute> is #write or #all and the directory's security attributes show the directory is writable, the method will also attempt to create a temporary file in the directory to confirm it is writable.
if testFileAttribute: is false or not specified, or <file_name> specifies a directory, the file attributes on the file are not included in the test.
If testFileAttribute: is true and <file_name> specifies a file, the file attributes (read, write, execute) are AND-ed with the security attributes.
Available in 3ds Max 2010 and higher.
Returns true if the specified directory exists and the directory can be written into.
Available in 3ds Max 2010 and higher.
In 3ds Max 6 and higher, returns the current 3dsmax.ini file as a string. For some products that store the ini settings in the registry, this method returns undefined. See also Accessing INI File Keys.