file exists

Tests whether a file or a folder exists.

file exists NAME

Description

Gives 1 when NAME is a file, a folder, or another entry of the file system, else 0. A path that leaves the root folder gives 0.

Arguments

ArgumentTypeDefaultDescription
NAMEpathrequiredThe path.

Returns

1 or 0.

Examples

% set f [open n.txt w]; close $f
> file exists n.txt
1

% file exists nope.txt
0

Errors

% file exists
wrong # args: should be "file exists name"
-errorcode TCL WRONGARGS

Facts

Capability
file. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also