External File Methods

getFiles <wild_card_filename_string>

Returns an array of file names that match the given wild-card path name. The following example 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:

files = getFiles "c:\\foo\\*.max"

for f in files do (loadMAXFile f; print objects)

getFiles() can also be used to determine if a file exists. For example, the following function will return true if the specified file name exists:

fn existFile fname = (getfiles fname).count != 0

getDirectories <wild_card_directory_name_string>

Returns an array of directory paths that match the given wild-card directory path name.

makeDir <directory_path_string>

Creates a new directory with the given name. Returns true on success, false on failure.

deleteFile <filename_string>

Deletes the named file. Fails if the file is open in MAXScript. Returns true on success, false on failure.

renameFile <old_filename_string> <new_filename_string>

Renames the old file to the new file. This can also be used to move a file between directories. Fails if new file already exists or if the old file is open in MAXScript. Returns true on success, false on failure.

copyFile <existing_filename_string> <new_filename_string>

Copies the existing file to the new file. Fails if the new file already exists, the new file cannot be created, or the existing file is open in MAXScript. Returns true on success, false on failure.

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:

#readOnly

#hidden

#system

#directory

#archive

#temporary

#normal

getFileModDate <filename_string>

Returns a String value containing the modification date for the specified file, for example "1/29/99 1:52:05 PM".

getFileCreateDate <filename_string>

Returns a String value containing the creation date for the specified file.

getFileVersion <filename_string>

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. For example:

GetFileVersion "g:\\3dsmax25\3dsmax.exe"

returns "2,5,0,0 2,5,0,0"

Examples:

for f in getFiles "3dsmax\\maps\\*.jpg" do deleteFile f

for d in getDirectories "D:\\foo\\*" do

for f in getFiles (d + "*.*") do

copyFile f ("C:\\temp\\" + getFilenameFile f + getFilenameType f)

if (getFiles "foo.max").count == 0 then print "File missing"

See also