> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guide/file-and-folder/file-exists.md).

# File exists

This action helps the tool check whether a file already exists on the computer. The result returned is very simple: True (if the file is found) or False (if not found).

* Purpose: Used in conjunction with the `If` block to handle more intelligently, avoiding situations where the tool encounters errors or stops abruptly when you request it to open a file that does not actually exist.

🎥 Watch the tutorial video: [Here](https://youtu.be/EH7olDLAb9c).

#### Configuration parameters:

* File Path: The absolute path to the file to be checked on the computer (e.g., `D:\data\accounts.txt`).
* Output variable: The name of the variable that stores the check result (`True` or `False`).

#### Practical example: Check the configuration file before running the script

Suppose you write a script to automatically fill in information and require the script to read data from the file `D:\GPM\config.json`. If the user forgets to create this file or enters the wrong path, the script will encounter a system error when it reaches the file reading command.

To handle this safely, you configure the script as follows:

* Step 1: Call the File exists action, enter the path `D:\GPM\config.json`, and name the output variable `$isFileReady`.
* Step 2: Use the If block to check: `If $isFileReady = False`.
* Step 3: Inside this If block, you call the Throw action with the content: `"Error: You have not created the config.json file on drive D, please check again!"`.

Result: The script will automatically check first. If the file does not exist, it will proactively stop the flow and trigger a visual red alert to let you know, instead of trying to continue and crashing the script.

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-4693a8938e77d89e696d180171fc1fb69ab0238b%2Fff-01.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gpmautomate.com/automate-en/action-guide/file-and-folder/file-exists.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
