Argument | Description | Types / Required |
path | The path of the directory to create. | string
required |
The
Path.createDirectory action creates a directory if it does not already exist. If necessary, parent directories will be added to support the creation of the directory.
Directories can also be created using the
dircreate function.
The action returns a string containing the fully evaluated path of the directory.
The action throws an exception if any of its arguments are not specified in a valid form or if the directory cannot be created.
// get a listing of all images
const imageListing = CS.Path.getDirectoryListing({
path: "Images",
filter: "|FileType.Image"
});
// when there are images...
if( imageListing.paths.length > 0 ) {
// ...create the backup directory, suffixed with the UNIX time
const backupDirectory = CS.Path.createDirectory({
path: `Images-Backup-${Date.now()}`
});
// ...and copy over all the images
CS.File.copy({
source: imageListing.paths,
destination: backupDirectory
});
}