Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions external_plugins/batch-file-renamer/.zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "batch-file-renamer",
"version": "0.1.0",
"description": "Rename a whole folder of files by rules — find/replace or regex, name templates with numbering, dates and folder names, case and space clean-up, lower-case extensions and per-file manual names. See old → new for every file and every clash before anything changes, rename safely (swaps and case-only changes work), keep a log, and undo the last rename. Runs locally; no API keys.",
"description_i18n": {
"en": "Rename a whole folder of files by rules — find/replace or regex, name templates with numbering, dates and folder names, case and space clean-up, lower-case extensions and per-file manual names. See old → new for every file and every clash before anything changes, rename safely (swaps and case-only changes work), keep a log, and undo the last rename. Runs locally; no API keys.",
"zh-CN": "按规则批量重命名整个文件夹:查找替换或正则、带序号/日期/文件夹名的命名模板、大小写和空格整理、扩展名统一小写,也可逐个手动指定新名。改名前就能看到每个文件的“原名 → 新名”和所有冲突,安全执行(互换名字、只改大小写也没问题),留下改名记录,还能撤销上一次改名。在本地运行,无需 API 密钥。"
},
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"keywords": [
"rename",
"batch rename",
"file names",
"regex",
"numbering",
"批量重命名",
"改名",
"文件名",
"序号",
"正则"
],
"skills": "skills",
"mcpServers": {
"batch-file-renamer": {
"type": "stdio",
"command": "node",
"args": [
"${ZCODE_PLUGIN_ROOT}/dist/server.mjs"
],
"cwd": "${ZCODE_PROJECT_DIR}",
"timeoutMs": 900000,
"env": {
"ZCODE_WORKSPACE_ROOT": "${ZCODE_PROJECT_DIR}"
}
}
},
"ui": {
"surfaces": [
{
"id": "editor",
"title": {
"zh-CN": "批量重命名",
"en-US": "Batch File Renamer"
},
"icon": "text-cursor-input",
"server": "batch-file-renamer",
"resourceUri": "ui://batch-file-renamer/panel.html",
"availability": "session"
}
]
}
}
21 changes: 21 additions & 0 deletions external_plugins/batch-file-renamer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Penova

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 52 additions & 0 deletions external_plugins/batch-file-renamer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Batch File Renamer

Rename a whole folder of files by rules — find/replace or regex, name templates with numbering, dates and folder names, case and space clean-up, lower-case extensions and per-file manual names. See old → new for every file and every clash before anything changes, rename safely (swaps and case-only changes work), keep a log, and undo the last rename. Runs locally; no API keys.

## Features

- **Rules**: find/replace (plain or regex with $1), a name template with {name} {n} {date} {parent} {ext}, numbering start and digits, numbering by name or modified time.
- **Clean-up**: lower/UPPER/Title case, spaces to - or _ or removed, runs of spaces collapsed, extensions lower-cased, illegal characters (\ / : * ? " < > |) replaced.
- **Manual names**: type a new name for any file in the table; the extension is kept if you leave it out.
- **Safety**: duplicate targets, names that already belong to other files and broken regexes are errors and block the rename; renaming is two-step so swaps and case-only changes work, and it rolls back if something fails.
- **Undo**: the last rename is logged and can be reverted with the “Undo” button (it is never part of “Export all”).
- **Panel**: pick input files, adjust settings, see problems, edit any cell in the table, preview the result and export — all in the ZCode side panel. Edits are saved in `batch-file-renamer/<project>.project.json` and kept until you re-open the inputs.

## Usage

Ask the agent in ZCode Desktop:

- "Rename the photos in 相册/ to 杭州-001.jpg, 杭州-002.jpg … in date order"
- "In 扫描件/, replace “scan_” with “合同-” and make extensions lower-case"
- "Undo the last rename"

## Tools

| Tool | Purpose |
|---|---|
| `rename_open` | List the files in a workspace folder and preview their new names. Opens the panel |
| `rename_edit` | Change settings, edit cells by row, add or remove rows |
| `rename_status` | Show the current rows, issues and summary |
| `rename_export` | Write rename-plan.csv, rename the files on disk (with rename-log-*.csv), or undo the last rename |

Output goes to `batch-file-renamer/<project>/` in the workspace.

## Scope (v0.1)

- Renames files only, not folders, inside the workspace; hidden files are skipped.
- Up to 5 folders and 5,000 files per project; subfolders are optional.
- Reading EXIF dates for photo names is a separate plugin (Photo Date Organizer).

## Privacy, network and files

- **Everything runs locally.** No network, no uploads, no API keys or accounts.
- Reads only the files you choose. Writes only the `batch-file-renamer/` folder in the workspace; it also renames files inside the folder you pick, but only when you click “Rename files” (or “Undo last rename”). No hooks.

## Build and test (developers)

- Source: `ui-plugins/batch-file-renamer/`.
- Build: `pnpm install --frozen-lockfile && pnpm build`, then add `dist/local-marketplace` as a local source.
- Tests: `pnpm --filter @penova/plugin-batch-file-renamer test` and `test:e2e` (needs Chrome; sample files in `test/samples/`).

## Third-party components and licenses

MIT licensed (author: Penova). Bundled: MCP SDK and ext-apps (MIT), zod (MIT); the full list is in `dist/THIRD_PARTY_NOTICES.txt`.
52 changes: 52 additions & 0 deletions external_plugins/batch-file-renamer/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 批量重命名

按规则批量重命名整个文件夹:查找替换或正则、带序号/日期/文件夹名的命名模板、大小写和空格整理、扩展名统一小写,也可逐个手动指定新名。改名前就能看到每个文件的“原名 → 新名”和所有冲突,安全执行(互换名字、只改大小写也没问题),留下改名记录,还能撤销上一次改名。在本地运行,无需 API 密钥。

## 功能

- **规则**:查找替换(普通文本或正则,可用 $1)、命名模板 {name} {n} {date} {parent} {ext}、起始序号和位数,按文件名或修改时间编号。
- **整理**:全小写/全大写/首字母大写,空格改成 - 或 _ 或去掉,合并连续空格,扩展名统一小写,非法字符(\ / : * ? " < > |)自动替换。
- **手动改名**:在表格里给任意文件填新名字,不写扩展名就保留原扩展名。
- **安全**:新名字重复、和其他文件撞名、正则写错都会报错并阻止改名;改名分两步,互换名字和只改大小写都能正确处理,中途出错会自动还原。
- **撤销**:上一次改名有记录,可用“撤销上次改名”按钮还原(“全部导出”不会触发撤销)。
- **面板**:在 ZCode 侧栏里选择输入文件、调整设置、查看问题、直接修改表格里的任意单元格、预览成品并导出。修改保存在 `batch-file-renamer/<项目>.project.json`,重新打开输入文件前一直保留。

## 使用方法

在 ZCode 桌面端对助手说:

- “把 相册/ 里的照片按时间顺序改成 杭州-001.jpg、杭州-002.jpg……”
- “扫描件/ 里把“scan_”换成“合同-”,扩展名统一小写”
- “撤销刚才的改名”

## 工具

| 工具 | 作用 |
|---|---|
| `rename_open` | 列出工作区文件夹里的文件并预览新文件名,并打开面板 |
| `rename_edit` | 修改设置、按行修改单元格、新增或删除行 |
| `rename_status` | 查看当前数据、问题和汇总 |
| `rename_export` | 导出改名清单 rename-plan.csv、实际改名(附 rename-log-*.csv),或撤销上次改名 |

导出文件写到工作区的 `batch-file-renamer/<项目>/` 文件夹。

## 范围(v0.1)

- 只改文件名、不改文件夹名,范围限于工作区;隐藏文件会跳过。
- 每个项目最多 5 个文件夹、5,000 个文件;子文件夹可选。
- 按照片 EXIF 拍摄日期命名请用另一个插件(照片按日期整理)。

## 隐私、网络与文件

- **全部在本地运行。** 不联网、不上传,不需要 API 密钥或账号。
- 只读取你选择的文件,只写入工作区的 `batch-file-renamer/` 文件夹;另外只有在你点“执行改名”(或“撤销上次改名”)时,才会重命名你所选文件夹里的文件。没有 Hook。

## 构建与测试(开发者)

- 源码:`ui-plugins/batch-file-renamer/`。
- 构建:`pnpm install --frozen-lockfile && pnpm build`,然后把 `dist/local-marketplace` 添加为本地来源。
- 测试:`pnpm --filter @penova/plugin-batch-file-renamer test` 和 `test:e2e`(需要 Chrome;样例文件在 `test/samples/`)。

## 第三方组件与许可证

MIT 许可(作者:Penova)。打包的组件:MCP SDK 与 ext-apps(MIT)、zod(MIT);完整列表见 `dist/THIRD_PARTY_NOTICES.txt`。
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: batch-file-renamer
description: 按规则批量重命名整个文件夹:查找替换或正则、带序号/日期/文件夹名的命名模板、大小写和空格整理、扩展名统一小写,也可逐个手动指定新名。改名前就能看到每个文件的“原名 → 新名”和所有冲突,安全执行(互换名字、只改大小写也没问题),留下改名记录,还能撤销上一次改名。在本地运行,无需 API 密钥。 用户提到“批量改名 / 重命名 / 改文件名 / 文件名加序号 / 撤销改名”时使用。
---

# 批量重命名

1. `rename_open(inputs, settings?, project?)`:列出工作区文件夹里的文件并预览新文件名。inputs 是工作区相对路径。
- 结果里有汇总、问题列表(错误 / 提醒)和前几行数据,每行有编号 `#n`。
- inputs 传文件夹路径;只改某类文件用 settings.only(如 "jpg,png");要子文件夹设 recursive: true。
2. 向用户简要说明结果,先说错误和需要确认的地方,不要逐行念。
3. 用户要改时调用 `rename_edit(project, settings?, set?: [{row, values}], add?, remove?)`。
- 规则写在 settings(find/replace/regex/template/start/pad/case/spaces/extCase/sort);单个文件用 `set: [{row, values: {override: "新名"}}]`。
4. `rename_export(project, formats?)`:导出改名清单 rename-plan.csv、实际改名(附 rename-log-*.csv),或撤销上次改名。把文件路径告诉用户。
5. 先 `rename_export` 用 formats ["plan"] 给用户看清单;用户确认后再 formats ["rename"]。撤销用 formats ["undo"]。有 error 时不要尝试改名。
48 changes: 48 additions & 0 deletions marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,54 @@
"把上一个 Hi3D 任务生成的模型按角色拆分成部件"
]
}
},
{
"name": "batch-file-renamer",
"componentTypes": [
"ui"
],
"source": "./external_plugins/batch-file-renamer",
"displayName": "Batch File Renamer",
"displayName_i18n": {
"en": "Batch File Renamer",
"zh-CN": "批量重命名"
},
"description": "Rename a whole folder of files by rules — find/replace or regex, name templates with numbering, dates and folder names, case and space clean-up, lower-case extensions and per-file manual names. See old → new for every file and every clash before anything changes, rename safely (swaps and case-only changes work), keep a log, and undo the last rename. Runs locally; no API keys.",
"description_i18n": {
"en": "Rename a whole folder of files by rules — find/replace or regex, name templates with numbering, dates and folder names, case and space clean-up, lower-case extensions and per-file manual names. See old → new for every file and every clash before anything changes, rename safely (swaps and case-only changes work), keep a log, and undo the last rename. Runs locally; no API keys.",
"zh-CN": "按规则批量重命名整个文件夹:查找替换或正则、带序号/日期/文件夹名的命名模板、大小写和空格整理、扩展名统一小写,也可逐个手动指定新名。改名前就能看到每个文件的“原名 → 新名”和所有冲突,安全执行(互换名字、只改大小写也没问题),留下改名记录,还能撤销上一次改名。在本地运行,无需 API 密钥。"
},
"version": "0.1.0",
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"category": "productivity",
"keywords": [
"rename",
"batch rename",
"file names",
"regex",
"numbering",
"批量重命名",
"改名",
"文件名",
"序号",
"正则"
],
"examplePrompts": [
"Rename the photos in 相册/ to 杭州-001.jpg, 杭州-002.jpg … in date order",
"In 扫描件/, replace “scan_” with “合同-” and make extensions lower-case",
"Undo the last rename"
],
"examplePrompts_i18n": {
"zh-CN": [
"把 相册/ 里的照片按时间顺序改成 杭州-001.jpg、杭州-002.jpg……",
"扫描件/ 里把“scan_”换成“合同-”,扩展名统一小写",
"撤销刚才的改名"
]
}
}
]
}
Loading