> For the complete documentation index, see [llms.txt](https://chaoses-ib.gitbook.io/directory-opus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chaoses-ib.gitbook.io/directory-opus/guan-fang-shou-ce/readme.zh-10/rename_macro_language.zh.md).

# 重命名宏语言

尽管你不需要了解重命名宏语言（使用[宏生成器](/directory-opus/guan-fang-shou-ce/readme.zh-2/readme.zh-1/readme.zh/readme.zh-1/rename_macros.zh.md)容易得多！），但这里仍对其进行描述以供参考。

![](/files/RsvDaJWap57WpjVWrjId)

宏语言描述一个或多个操作，每个操作相对每个文件名开头或结尾的位置。上面是一个简单的宏，可从每个名称的末尾移除 6 个字符，并在每个名称的开头插入单词“Final”。

每个宏表达式的组成部分为：

1. **锚点**: 操作宏的第一个字符为 **L** 或 **R**，用以表示位置相对于文件名的**左**或**右**。
2. **偏移量**: 接下来的字符是从锚点位置的偏移量。
3. **操作**: （可选）其后可能出现一个以下操作字符。
   * **–** 移除文本
   * **C** 复制文本到剪贴板
   * **X** 剪切文本到剪贴板
   * **V** 粘贴剪贴板内容
4. **长度:** 对于 \*\*–\*\*（移除）、**C**（复制）和 **X**（剪切），接下来是移除、复制或剪切的长度（以字符为单位）。你可以使用 \* 作为长度以表示每个名称的末尾（长度有多长都行）。
5. **插入**: （可选）要在名称的当前位置插入字符，请使用 **+**，后跟要插入的文本。
6. **分隔符**: 如果宏包含附加操作，则应使用 **/** 字符进行分隔。

利用这些信息，我们现在可以解码上面示例中显示的宏：

* **R0-6**: 右锚点，距离文件名末尾 0 个字符，**移除** 6 个字符。
* **L0+Final**: 左锚点，距离文件名开头 0 个字符，**插入**单词“Final”。

这是该宏在操作中的一个示例：

![](/files/H8s41tiwDg6M89VybDWn)

如你所见，每个文件名的后缀 **\_draft** 已被移除（通过 **R0-6** 表达式），并且已插入前缀 **Final**（通过 **L0+Final** 表达式）。

我们来看一个更复杂的宏示例。

![](/files/1sPDR8FaTLSf7BTMfiUK)

使用前一页的指南，我们可以分解并解码如下每个组件：

* **R0-6**: 右锚点，距离文件名末尾 0 个字符，**移除** 6 个字符。
* **R0X2**: 右锚点，距离末尾 0 个字符，**剪切** 2 个字符到剪贴板。
* **R0-1**: 右锚点，距离末尾 0 个字符，**移除** 1 个字符。
* **R7V**: 右锚点，距离末尾 7 个字符，**粘贴**剪贴板内容。
* **R7+**.: 右锚点，距离末尾 7 个字符，**插入**一个句点。
* **R0X2**: 右锚点，距离末尾 0 个字符，**剪切** 2 个字符到剪贴板。
* **R0-1**: 右锚点，距离末尾 0 个字符，**移除** 1 个字符。
* **R4V**: 右锚点，距离末尾 4 个字符，**粘贴**剪贴板内容。
* **R4+**.: 右锚点，距离末尾 4 个字符，**插入**一个句点。
* **L0+Final**: 左锚点，距离文件名开头 0 个字符，**插入**单词“Final”。

如你所见，该宏利用宏语言的剪贴板功能。剪贴板操作是对每个文件名进行的 - 当它说“**剪切** 2 个字符到剪贴板”时，这意味着每个文件名（对每个文件而言可能不同）中两个字符被剪切到剪贴板。当然，这意味着你可以使用简单的剪贴板操作来移动文件名中的部分。

这是该宏在使用中的示例：

![](/files/Qu10u85O7AfbYtzcwa74)

与第一个示例类似，每个文件名的后缀 **\_draft** 已被移除（通过 **R0-6** 表达式），并且已插入前缀 **Final**（通过 **L0+Final** 表达式）。但除此之外，每个文件名中的日期已重新排列。通过使用多个剪贴板剪切/插入步骤，**2007-10-15** 已变为 **15.10.2007**。


---

# 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:

```
GET https://chaoses-ib.gitbook.io/directory-opus/guan-fang-shou-ce/readme.zh-10/rename_macro_language.zh.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
