Item objects represent a file or a folder on the file system, whether it exists or not, based on its path.
Item objects, you can:
root/home/here or scriptFile/scriptFolder globals
File()/Folder()/Item() globals with an absolute path
file() or folder() on a Folder
cli method, using a corresponding type definition
To check whether a given Item object is a File or a Folder, you can use the instanceof operator.
Item
Item(String absolutePath)
Returns a new File or Folder instance for absolutePath, depending on the actual kind of the item on the filesystem.
Use this global when you don't know the item kind in advance, such as when accepting user input. Otherwise, use one of the File()/Folder() globals.
On Windows, the path can optionally include a drive identifier.
Throws if the item doesn't exist.
| absolutePath |
The absolute path to the item to get.
|
const mysteryPath = '/path/to/something'; // a path we got from outside the script
const item = Item(mysteryPath);
if (item instanceof File) {
// item is a file
} else if (item instanceof Folder) {
// item is a folder
}