Skip to content

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.

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 false if path is a folder (for folders use the dirExists(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).
ParameterTypeDefaultDescription
pathstring—Path of the file to check.

None.

Returns a bool: true if the file exists; false if it does not, if it is a folder, or if it cannot be accessed.

It practically never fails: only when the path expression evaluates to null ('path' is required.).

Read a file only if it is there; otherwise, use a default value:

File Exists path = "C:/config/settings.txt" → output: exists
If condition = exists
├─ then:
│ Read File path = "C:/config/settings.txt" → output: config
└─ else:
Log level = warning message = "No settings file; using default values"
  • Read File — read the file once you know it exists.
  • List Files — check/list several files in a folder.
  • If — branch on the result.