> 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/huong-dan-cac-action/file-and-folder/file-write-all-text.md).

# File write all text

File write all text là hành động dùng để ghi một chuỗi văn bản vào một file định dạng `.txt` trên máy tính.

🎥 Xem thêm video hướng dẫn: [Tại đây](https://youtu.be/EH7olDLAb9c).

Hành động này sở hữu cơ chế vận hành đặc biệt (ghi đè và tự động tạo mới):

* Nếu file chưa tồn tại: Hệ thống sẽ tự động tạo mới file `.txt` theo đường dẫn đã chỉ định rồi ghi nội dung vào.
* Nếu file đã tồn tại: Hệ thống sẽ xóa sạch toàn bộ nội dung cũ đang có trong file và ghi đè nội dung mới vào.

#### Tham số cấu hình:

* File Path: Đường dẫn tuyệt đối dẫn đến file `.txt` muốn ghi dữ liệu (Ví dụ: `D:\GPM\status.txt`).
* Text: Nội dung văn bản thô (hoặc biến chứa văn bản) mà bạn muốn ghi vào file.

#### Ví dụ thực tế: Tự động khởi tạo file báo cáo trạng thái mới

Giả sử bạn bắt đầu chạy một kịch bản tương tác tài khoản mới vào đầu ngày. Bạn muốn kịch bản tự động làm sạch (hoặc tạo mới) một file văn bản có tên là `report.txt` ở ổ D, sau đó ghi dòng chữ chào mừng đầu tiên vào đó để chuẩn bị lưu nhật ký cho ngày hôm nay.

* Cách cấu hình:
  * Gọi hành động File write all text.
  * File Path: Điền `D:\GPM\report.txt`.
  * Text: Điền nội dung: `"--- Nhật ký chạy kịch bản ngày hôm nay ---"`.
* Kết quả:
  * Nếu chưa có file `report.txt`, hệ thống tự động tạo file này tại thư mục `D:\GPM\`.
  * Nếu file đã có sẵn từ hôm qua (chứa đầy chữ cũ), hệ thống sẽ dọn sạch bách nội dung cũ đó, biến file thành file trắng rồi ghi vào dòng chữ `"--- Nhật ký chạy kịch bản ngày hôm nay ---"`.

<figure><img src="/files/wOkc5y7NCPkQxtUoJka7" 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/huong-dan-cac-action/file-and-folder/file-write-all-text.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.
