> 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/cao-zuo/zhong-ming-ming.md).

# 重命名

## 高级重命名

高级重命名可以实现复杂的批量重命名。支持通配符、宏（编辑录制）和正则表达式，能够插入序号和元数据字段，也可以使用 JS/VBS 脚本进行自定义处理。配置好的重命名规则可以保存为预设（上图左侧），便于之后再次使用。

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-b20d047078f3529ff52f28d9756d3c7bbc5e78f6%2F%E9%AB%98%E7%BA%A7%E9%87%8D%E5%91%BD%E5%90%8D-v13.png?alt=media)

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-2246a53392141216bdf418b46a38feabca10e719%2F%E9%AB%98%E7%BA%A7%E9%87%8D%E5%91%BD%E5%90%8D2-v13.png?alt=media)

相关的内置操作如下：

| 操作    | 快捷键    | 工具栏    |
| ----- | ------ | ------ |
| 高级重命名 | Ctrl+3 | 操作/重命名 |

<details>

<summary>v12</summary>

<img src="https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-b5bb773f653e500f022adaf8e364a4485fbcba64%2F%E9%AB%98%E7%BA%A7%E9%87%8D%E5%91%BD%E5%90%8D.png?alt=media" alt="" data-size="original">

</details>

## 元数据

详见[使用元数据重命名](/directory-opus/guan-fang-shou-ce/readme.zh-2/readme.zh-1/readme.zh/renaming_with_metadata.zh.md)。

## 预设

除了在高级重命名对话框中使用，预设也可以直接在工具栏中调用：

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-7ed16e2aa2c2e63cfa6b2cfce7d4565edd242387%2F%E9%A2%84%E8%AE%BE-%E5%B7%A5%E5%85%B7%E6%A0%8F.png?alt=media)

或者通过命令调用，例如：

```cmd
Rename PRESET="文件编号"
```

如果预设有参数，可以通过 `Rename` 命令的 `SCRIPTARG` 参数进行指定，例如：

```cmd
Rename PRESET="EncodingConvert" SCRIPTARG srcEncoding:1 dstEncoding:3
```

## 重命名对话框的默认状态

默认情况下，重命名对话框在打开时不会保留上次使用时的状态。通过对话框左上角的 `最近重命名` 按钮（F4）可以手动恢复上次状态。

如果希望对话框自动恢复上次状态，可以将相关按钮中的 `Rename ADVANCED` 命令替换为 `Rename ADVANCED PRESET=last`。

如果只希望修改默认模式，则可以替换为下列命令之一：

* 查找并替换：`Rename ADVANCED PRESET=findrep`
* 正则表达式：`Rename ADVANCED PRESET=regexp`
* 正则表达式 + 查找并替换：`Rename ADVANCED PRESET=regexpfindrep`

`regexpfindrep` 虽然在 v12.27 才被加入文档，但实际上在之前的版本中也是可用的。

## 文本编辑器重命名

相较于其它方法，通过文件编辑器进行重命名更加灵活，可以组合手动编辑、查找替换、其它工具和脚本语言来进行处理。

DOpus 的重命名对话框支持导出文件名列表到剪贴板及导入，可以通过该功能实现文本编辑器重命名。例如：

1. 复制旧文件名

   ![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-b2edf660a26799313a5d08e6df910c925a0e6cd6%2F%E5%A4%8D%E5%88%B6.png?alt=media)
2. 编辑并粘贴新文件名

   ![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-259bf2dae539caf2c11d388dafbb012ce7f2555b%2F%E7%B2%98%E8%B4%B4.png?alt=media)

   除了直接从剪贴板导入文件名外，也可将剪贴板中的列表导入为文件名的前缀或后缀。

也可通过此功能实现交换两组文件的名称。

## 对选中文件夹中的文件进行重命名

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-6227e9616b637546c14c432e9d2a19cdb283cb82%2F%E9%87%8D%E5%91%BD%E5%90%8D-%E9%80%89%E4%B8%AD%E6%96%87%E4%BB%B6%E5%A4%B9.png?alt=media)

在高级重命名中，选中“重命名选中文件夹中的文件”即可对选中文件夹中的文件进行重命名。可以使用一些字段来引用父文件夹的名称：

* 使用 `{parent}` 可以引用文件的父文件夹名，如上图所示；
* 使用 `{parent[数字]}` 可以引用多级父文件夹名，例如 `{parent2}` 可以引用父文件夹的父文件夹名；
* 使用 `{parentbase}` 可以引用选中文件夹的父文件夹，或者通过 `{parentbase[数字]}` 来引用多级父文件夹。
* 不过不能直接引用选中文件夹的名称。

需要注意的是，这个选项也会对选中文件夹中所有子文件夹的文件进行重命名，且不能关闭。

在 `Rename` 命令中，可以使用 [`RECURSE`](https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Rename.htm:~:text=RECURSE) 来开启该递归模式，例如：

```cmd
Rename PATTERN * TO {parent}--* RECURSE
```

## 重命名脚本

* [PercentDecode](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/PercentDecode.js)（百分号解码）

  解码百分号编码（URL编码），例如将 `%E4%BD%A0%E5%A5%BD` 和 `%u4F60%u597D` 解码为 `你好`。
* [RandomString](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/RandomString.js)（随机文本）

  替换新名称中的 `{randomString}` 为随机文本。
* [EncodingConvert](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/EncodingConvert.js)（编码转换）

  主要用于修复文件名乱码，例如将 GBK 编码的 `嬻偺嫬奅 椉媀幃` 修复为 Shift-JIS 编码的 `空の境界 両儀式`。

  ![](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/9f6ac321b31d21bb20ed46b678f7d5f722865fb1/Rename%20Scripts/images/EncodingConvert.zh-Hans.png?raw=true)

  支持 UTF-8、GBK、Big5、Shift-JIS 和 EUC-KR 编码。
* [繁体中文转简体](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/繁体中文转简体.js)

  例如将 `邊緣行者` 转换为 `边缘行者`。
* [简体中文转繁体](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/简体中文转繁体.js)

  例如将 `边缘行者` 转换为 `邊緣行者`。
* [中文数字转阿拉伯数字-WSQL](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/中文数字转阿拉伯数字-WSQL.vbs)

  例如将 `一百二十三` 转换为 `123`。支持大写数字。
* [阿拉伯数字转中文数字-WSQL](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/阿拉伯数字转中文数字-WSQL.vbs)

  例如将 `123` 转换为 `一百二十三`。支持大写数字。
* [阿拉伯数字转中文数字-无单位](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/阿拉伯数字转中文数字-无单位.js)

  例如将 `123` 转换为 `一二三`。支持大写数字。
* [中英混排加空格](https://github.com/Chaoses-Ib/IbDOpusScripts/blob/main/Rename%20Scripts/中英混排加空格.js)

  在汉字和英文单词之间添加空格，例如将 `你好world` 转换为 `你好 world`。

## 批量重命名内部冲突

在批量重命名时，可能会出现某一文件的新名称与另一文件的旧名称冲突的情况，比如同时将 `文件夹1` 重命名为 `文件夹3`，将 `文件夹3` 重命名为 `文件夹1`。部分重命名工具无法正确处理这种情况，但 DOpus 和 Total Commander 都可以正确处理：

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-44bc44b6a6461c525cae825d1ebcddf664e60986%2F%E5%86%B2%E7%AA%81.png?alt=media)


---

# 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://chaoses-ib.gitbook.io/directory-opus/cao-zuo/zhong-ming-ming.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.
