File Exists
File Exists
Section titled “File Exists”Type: file-exists · Package: Filesystem Activities v1.0.6 · Output: bool
Checks whether a file exists at the given path and returns true or false. It is the safe way to get ahead of errors: make sure a file is there before reading it, or wait for it to appear before processing it.
How it works
Section titled “How it works”Returns true if there is a file at path, false otherwise. It does not throw when the file is missing — that is its purpose. The result usually feeds an If.
- It also returns
falseifpathis a folder (for folders use thedirExists(path)function in an expression), if the path is invalid, or if the robot’s account cannot see it. - It is an instant check: it does not wait for the file to appear. To wait, combine it with While and Delay.
- The same check is available in expressions as
fileExists(path).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the file to check. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”Returns a bool: true if the file exists; false if it does not, if it is a folder, or if it cannot be accessed.
Common errors
Section titled “Common errors”It practically never fails: only when the path expression evaluates to null ('path' is required.).
Example
Section titled “Example”Read a file only if it is there; otherwise, use a default value:
File Exists path = "C:/config/settings.txt" → output: existsIf condition = exists ├─ then: │ Read File path = "C:/config/settings.txt" → output: config └─ else: Log level = warning message = "No settings file; using default values"Related activities
Section titled “Related activities”- Read File — read the file once you know it exists.
- List Files — check/list several files in a folder.
- If — branch on the result.