Argument | Description | Types / Required |
path | The path of a directory or file. | string
required |
The
Path.getPathInfo action returns information about a
path, including about whether the path exists. Information about directories is specified without a trailing slash.
The action returns an object containing the properties:
Property | Value |
"path" | A string containing the fully evaluated path. |
"name" | A string containing the name of the path (the path with the directory information removed). |
"exists" | A boolean value indicating if the path exists. |
If the path exists, the object also contains:
Property | Value |
"type" | A string indicating if the path is a "directory" or "file". |
"modifiedTime" | A number containing the modified date and time of the path in UNIX time. |
If the path exists and is a file, the object also contains:
Property | Value |
"extension" | A string containing the file extension without a preceding period. |
"contentType" | A string with the MIME type of the file (if known). |
"size" | A number containing the size of the file in bytes. |
The action throws an exception if any of its arguments are not specified in a valid form.
// select an image
const imagePath = CS.Path.selectFile({
title: "Select an Image",
filter: "|FileType.Image"
});
if( imagePath !== undefined ) {
// ensure that the file size is one megabyte or less
const imagePathInfo = CS.Path.getPathInfo({
path: imagePath
});
if( imagePathInfo.size > ( 1024 * 1024 ) ) {
throw new Error(`The image '${imagePathInfo.name}' is ${imagePathInfo.size} bytes but the maximum image size is 1 MB.`);
}
}