Working with files and directories
PowerMill contains a number of commands and functions for creating and manipulating files on disc. The following commands can be used to delete and copy files and directories:
DELETE FILE <filename>
DELETE DIRECTORY <directory>
COPY FILE <source-file> <destination file>
COPY DIRECTORY <source directory> <destination-directory>
The command CD
changes the working directory:
// change working directory to "C:\temp"
CD "C:\temp"
// change working directory back to where PowerMill
started from
CD
The command MKDIR
will create a directory path:
MKDIR "C:\temp\\output\pm_project"
The command will create all directories in the path if they do not exist already.
File and directory functions
PowerMill contains a number of parameter functions that can be used to examine the file structure of the disc:
string pwd()
— Returns the current working directory path.bool file_exists(filepath)
— Returns true if filepath is an existing file.bool dir_exists(dirpath)
— Returns true if dirpath is an existing directory.list list_files(string flags,string directory[, string filetype])
— Returns a list of files that match the flags and optional filetype. The flags parameter can be either'all'
,'files'
, or'dirs'
with an additional'+'
suffix. If the'+'
suffix is given then all subdirectories are listed.
Example
// get a list of all the files in the working directory
STRING LIST files = list_files("files",pwd())
// get all the stl files in the C:\temp directory
$files = list_files("files","c:\temp",".stl")
// get all the directories and subdirectories in the working directory
$files = list_files("dirs+", pwd())