Item

Overview

Item objects represent a file or a folder on the file system, whether it exists or not, based on its path.

To get or create Item objects, you can:

To check whether a given Item object is a File or a Folder, you can use the instanceof operator.

Methods and properties

Getting an instance from an absolute path

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.
sample Get an item of unknown kind by absolute path
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
}