> 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/append-line.md).

# File append line

文件追加行是用于在`.txt`格式文件的最后位置插入一行新文字的操作。

🎥 查看更多教程视频：[在这里](https://youtu.be/EH7olDLAb9c)。

与覆盖操作（文件写入所有文本）不同，此操作可以保留文件中之前的所有数据。

* 如果文件不存在：系统会自动根据指定路径创建新的`.txt`文件，然后进行插入文字。
* 如果文件已存在：系统会保留旧内容，在文件末尾自动换行并追加新数据行。

#### 配置参数：

* 文件路径：指向要追加数据的`.txt`文件的绝对路径（例如：`D:\GPM\history_log.txt`）。
* 文本：您想要追加到文件末尾的文本内容（或包含文本的变量）。

#### 实际示例：记录成功运行的账户日志

假设您运行一个交互脚本，并希望将已完成任务的账户列表保存到`success_accounts.txt`文件中，以便在一天结束时方便检查：

* 配置方式：在账户完成脚本末尾的交互步骤后，您调用文件追加行操作：
  * 文件路径：填写`D:\GPM\success_accounts.txt`。
  * 文本：传递包含账户名称的变量（例如：`$currentAccount`）。
* 结果：每当有一个流运行完成，该账户名称将整齐地按行追加到`success_accounts.txt`文件中（例如：第1行是`tk_01`，第2行是`tk_02`...），而不会丢失之前运行账户的数据。

<figure><img src="/files/7MGixmnNxEH8RWtFkqFo" 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 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/append-line.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.
