> 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-zh/cao-zuo-zhi-nan/file-and-folder/folder-exists.md).

# 文件夹存在

文件夹存在是一个用于检查指定路径上的文件夹是否存在于计算机硬盘上的操作。此操作的返回结果是一个逻辑值：True（如果找到文件夹）或 False（如果文件夹不存在）。

此操作通常用作在执行诸如创建新文件夹、删除文件夹或将文件移动到其中等操作之前的缓冲步骤，以确保脚本顺利运行而不会因路径错误而突然中断。

#### 配置参数：

* 文件夹路径：指向计算机上需要检查的文件夹的绝对路径（例如：`D:\GPM_Data`）。
* 输出变量：保存检查结果的变量名称（`True` 或 `False`）。

#### 实际示例：在下载之前检查个人资料图片文件夹

假设您有一个自动从网上下载头像的脚本，以将其保存到每个个人资料的专用文件夹中，结构为：`D:\GPM_Data\Profile_1`。如果此 `Profile_1` 文件夹尚未在 D 盘上创建，后续下载图片的操作将立即出错。

为了智能地处理此逻辑，您可以按如下配置：

* 步骤 1：调用文件夹存在操作，填写需要检查的文件夹路径为 `D:\GPM_Data\Profile_1`，将输出变量命名为 `$isFolderReady`。
* 步骤 2：使用条件语句 If 检查：`如果 $isFolderReady = False`（意味着该文件夹尚不存在）。
* 步骤 3：在 If 语句块内，调用创建文件夹操作，路径为 `D:\GPM_Data\Profile_1`，以便系统自动创建此文件夹。

结果：脚本将自动进行检查。如果文件夹不存在，它将自动创建，然后再进行下载，确保运行流程始终安全且不会崩溃。


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/file-and-folder/folder-exists.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
