Core JavaScriptExtendScript only
Object

File

Represents a file in the local file system in a platform-independent manner.

Hierarchy

Folder

File

Properties

NameType AccessDescription
String readonly The full path name for the referenced file in URI notation.
Boolean readonly If true, the object refers to a file system alias or shortcut.
Date readonly The creation date of the referenced file, or null if the object does not refer to a file on disk.
String readonly In Mac OS, the file creator as a four-character string. In Windows or UNIX, value is "????".
String readonly The localized name of the referenced file, without the path specification.
String read/write Gets or sets the encoding for subsequent read/write operations.
Boolean readonly When true, a read attempt caused the current position to be at the end of the file, or the file is not open.
String read/write A string containing a message describing the most recent file system error.
Boolean readonly If true, this object refers to a file or file-system alias that actually exists in the file system.
static String readonly The name of the file system.
String readonly The platform-specific full path name for the referenced file.
String readonly The full path name for the referenced file in URI notation.
Boolean read/write When true, the file is not shown in the platform-specific file browser.
Number read/write The size of the file in bytes.
String read/write How line feed characters are written in the file system.
Date readonly The date of the referenced file's last modification, or null if the object does not refer to a file on the disk.
String readonly The file name portion of the absolute URI for the referenced file, without the path specification.
Folder readonly The Folder object for the folder that contains this file.
String readonly The path portion of the absolute URI for the referenced file, without the file name.
Boolean read/write When true, prevents the file from being altered or deleted.
String readonly The path name for the object in URI notation, relative to the current folder.
String readonly The file type as a four-character string.

Methods

File

Creates and returns a new File object referring to a given file system location.

path? String The full or partial path name of the file, in platform-specific or URI format.
Boolean

Changes the path specification of the referenced file.

path String A string containing the new path, absolute or relative to the current folder.
Boolean

Closes this open file.

Boolean

Copies this object’s referenced file to the specified target location.

target String | File A string with the URI path to the target location, or a File object that references the target location.
void

Makes this file a file-system alias or shortcut to the specified file.

path String A string containing the path of the target file.
String

Decodes a UTF-8 encoded string as required by RFC 2396, and returns the decoded string.

uri String The UTF-8 encoded string to decode.
String

Encodes a string as required by RFC 2396, and returns the encoded string.

name String The string to encode.
Boolean

Executes or opens this file using the appropriate application, as if it had been double-clicked in a file browser.

String

Retrieves and returns the path for this file, relative to the specified base path, in URI notation.

basePath String A base path in URI notation.
Boolean

Reports whether a given encoding is available.

name String The encoding name.
Boolean

Opens the referenced file for subsequent read/write operations. The method resolves any aliases to find the file.

mode String The read-write mode, a single-character string.
type? String In Mac OS, the type of a newly created file, a 4-character string. Ignored in Windows and UNIX.
creator? String In Mac OS, the creator of a newly created file, a 4-character string. Ignored in Windows and UNIX.
File

Opens a dialog so the user can select one or more files to open.

prompt String The prompt text, displayed if the dialog allows a prompt.
filter? Varies A filter that limits the types of files displayed in the dialog.
multiSelect? Boolean When true, the user can select multiple files and the return value is an array.
File

Opens the built-in platform-specific file-browsing dialog, in which the user can select an existing file or files, and creates new File objects to represent the selected files.

prompt String A string containing the prompt text, if the dialog allows a prompt.
filter? Varies A filter that limits the types of files displayed in the dialog.
multiSelect? Boolean When true, the user can select multiple files and the return value is an array.
String

Reads the contents of the file, starting at the current position.

chars? Number An integer specifying the number of characters to read.
String

Reads a single text character from the file at the current position.

String

Reads a single line of text from the file at the current position.

Boolean

Deletes the file associated with this object from disk immediately, without moving it to the system trash.

Boolean

Renames the associated file.

newName String The new file name, with no path information.
File

Attempts to resolve the file-system alias or shortcut that this object refers to.

File

Opens a dialog so the user can select a file name to save to.

prompt String The prompt text, displayed if the dialog allows a prompt.
filter? Varies In Windows only, a filter that limits the types of files displayed in the dialog.
File

Opens the built-in platform-specific file-browsing dialog, in which the user can select an existing file location to which to save information, and creates a new File object to represent the selected file.

prompt String A string containing the prompt text, if the dialog allows a prompt.
filter? Varies In Windows only, a filter that limits the types of files displayed in the dialog.
Boolean

Seeks to a given position in the file.

pos Number The new current position in the file as an offset in bytes from the start, current position, or end, depending on the mode.
mode? Number 0–2 The seek mode.
Number

Retrieves the current position as a byte offset from the start of the file.

String

Creates and returns a serialized string representation of this object.

String

Converts this object to a string.

Boolean

Writes the specified text to the file at the current position.

text String A text string to be written.
Boolean

Writes a string to the file at the current position and appends a line-feed sequence.

text String A text string to be written.

Object of 2

Properties elsewhere that hold a File.

Parameter of 2

Method parameters that accept a File.

Return 6

Methods that return a File.