← 返回 Skills 市场
ollielin

bot File Processor

作者 ollielin · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
129
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install bot-file-processor
功能描述
通用文件处理技能,用于批量重命名和格式转换。当用户需要批量重命名文件(添加前缀/后缀、替换文本、编号重命名、正则表达式重命名)或转换文件格式(图片格式转换、PDF与图片互转、DOCX转PDF、Markdown转PDF)时使用此技能。
使用说明 (SKILL.md)

\r \r

File Processor - 文件处理技能\r

\r

概述\r

\r 此技能提供文件重命名和格式转换功能,用于批量处理文件的命名和格式。支持批量重命名操作和多种文件格式之间的转换。\r \r

使用时机\r

\r 当用户需要以下操作时使用此技能:\r \r 文件重命名:\r

  • 批量为文件添加前缀或后缀\r
  • 替换文件名中的部分文本\r
  • 按编号规则重命名文件\r
  • 使用正则表达式进行复杂重命名\r
  • 重命名单个文件\r \r 格式转换:\r
  • 图片格式转换 (JPG/PNG/WebP/BMP/TIFF 互转)\r
  • PDF 转为图片\r
  • 多张图片合并为 PDF\r
  • Word 文档 (DOCX) 转为 PDF\r
  • Markdown 文档转为 PDF\r \r

工作流程\r

\r

文件重命名流程\r

\r

  1. 确定重命名类型\r
    • 添加前缀/后缀: 使用 add_prefix()add_suffix()\r
    • 替换文本: 使用 replace_text()\r
    • 编号重命名: 使用 rename_with_numbering()\r
    • 正则表达式: 使用 rename_with_regex()\r \r
  2. 执行重命名\r
    • 创建 FileRenamer 实例,指定目录路径\r
    • 调用相应的重命名方法\r
    • 执行 execute() 完成重命名\r \r
  3. 验证结果\r
    • 检查文件是否按预期重命名\r
    • 确认无命名冲突\r \r

格式转换流程\r

\r

  1. 确定转换类型\r
    • 图片格式转换: 使用 convert_images()\r
    • PDF 转图片: 使用 convert_pdf_to_images()\r
    • 图片转 PDF: 使用 convert_images_to_pdf()\r
    • DOCX 转 PDF: 使用 convert_docx_to_pdf()\r
    • Markdown 转 PDF: 使用 convert_markdown_to_pdf()\r \r
  2. 执行转换\r
    • 创建 FormatConverter 实例\r
    • 调用相应的转换方法\r
    • 执行 execute() 完成转换\r \r
  3. 验证结果\r
    • 检查转换后的文件格式和质量\r
    • 确认文件完整性\r \r

使用方法\r

\r

文件重命名\r

\r

1. 批量添加前缀\r

\r

from scripts.rename_files import FileRenamer\r
\r
# 为所有文件添加前缀\r
renamer = FileRenamer("/path/to/directory")\r
renamer.add_prefix("new_")\r
renamer.execute()\r
```\r
\r
#### 2. 批量添加后缀\r
\r
```python\r
# 为所有文件添加后缀(在扩展名前)\r
renamer = FileRenamer("/path/to/directory")\r
renamer.add_suffix("_backup")\r
renamer.execute()\r
```\r
\r
#### 3. 替换文件名中的文本\r
\r
```python\r
# 将文件名中的 "old" 替换为 "new"\r
renamer = FileRenamer("/path/to/directory")\r
renamer.replace_text("old", "new")\r
renamer.execute()\r
```\r
\r
#### 4. 按编号规则重命名\r
\r
```python\r
# 将文件按名称排序,重命名为 photo_001.jpg, photo_002.jpg 等\r
renamer = FileRenamer("/path/to/directory")\r
renamer.rename_with_numbering(\r
    pattern="photo_{}.jpg",\r
    start_num=1,\r
    digits=3,\r
    sort_by="name"  # 也可为 "size" 或 "date"\r
)\r
renamer.execute()\r
```\r
\r
#### 5. 使用正则表达式重命名\r
\r
```python\r
# 使用正则表达式重命名\r
renamer = FileRenamer("/path/to/directory")\r
# 例如:将 "IMG_1234.jpg" 改为 "image_1234.jpg"\r
renamer.rename_with_regex(r"IMG_(\d+)", r"image_\1")\r
renamer.execute()\r
```\r
\r
#### 6. 预览模式(不实际执行)\r
\r
```python\r
# 使用 dry_run 模式预览重命名效果\r
renamer = FileRenamer("/path/to/directory", dry_run=True)\r
renamer.add_prefix("test_")\r
renamer.execute()  # 只显示预览,不实际重命名\r
```\r
\r
### 格式转换\r
\r
#### 1. 图片格式转换\r
\r
```python\r
from scripts.convert_format import FormatConverter\r
\r
# 将目录中的所有 JPG 图片转换为 PNG 格式\r
converter = FormatConverter()\r
converter.convert_images(\r
    directory="/path/to/images",\r
    target_format="png",\r
    quality=95\r
)\r
converter.execute()\r
```\r
\r
#### 2. PDF 转图片\r
\r
```python\r
# 将 PDF 转换为 PNG 图片\r
converter = FormatConverter()\r
converter.convert_pdf_to_images(\r
    pdf_path="/path/to/file.pdf",\r
    output_dir="/path/to/output",\r
    format="png",\r
    dpi=300\r
)\r
converter.execute()\r
```\r
\r
#### 3. 图片转 PDF\r
\r
```python\r
# 将目录中的图片合并为一个 PDF\r
converter = FormatConverter()\r
converter.convert_images_to_pdf(\r
    directory="/path/to/images",\r
    output_pdf="/path/to/output.pdf",\r
    sort=True  # 按名称排序\r
)\r
converter.execute()\r
```\r
\r
#### 4. DOCX 转 PDF\r
\r
```python\r
# 将 Word 文档转换为 PDF\r
converter = FormatConverter()\r
converter.convert_docx_to_pdf(\r
    docx_path="/path/to/document.docx",\r
    output_pdf="/path/to/output.pdf"\r
)\r
converter.execute()\r
```\r
\r
#### 5. Markdown 转 PDF\r
\r
```python\r
# 将 Markdown 文档转换为 PDF\r
converter = FormatConverter()\r
converter.convert_markdown_to_pdf(\r
    md_path="/path/to/document.md",\r
    output_pdf="/path/to/output.pdf"\r
)\r
converter.execute()\r
```\r
\r
## 脚本使用说明\r
\r
### rename_files.py\r
\r
文件重命名工具,提供以下命令行功能:\r
\r
```bash\r
# 添加前缀\r
python rename_files.py /path/to/directory prefix "new_prefix"\r
\r
# 添加后缀\r
python rename_files.py /path/to/directory suffix "_backup"\r
\r
# 替换文本\r
python rename_files.py /path/to/directory replace "old" "new"\r
\r
# 编号重命名\r
python rename_files.py /path/to/directory numbering "photo_{}.jpg" --start 1 --digits 3 --sort name\r
\r
# 正则表达式重命名\r
python rename_files.py /path/to/directory regex "IMG_(\d+)" "image_\1"\r
\r
# 预览模式(不实际执行)\r
python rename_files.py /path/to/directory prefix "test_" --dry-run\r
```\r
\r
### convert_format.py\r
\r
文件格式转换工具,提供以下命令行功能:\r
\r
```bash\r
# 图片格式转换\r
python convert_format.py images /path/to/images png --quality 95\r
\r
# PDF 转图片\r
python convert_format.py pdf-to-images /path/to/file.pdf /path/to/output --format png --dpi 300\r
\r
# 图片转 PDF\r
python convert_format.py images-to-pdf /path/to/images /path/to/output.pdf\r
\r
# DOCX 转 PDF\r
python convert_format.py docx-to-pdf /path/to/document.docx /path/to/output.pdf\r
\r
# Markdown 转 PDF\r
python convert_format.py md-to-pdf /path/to/document.md /path/to/output.pdf\r
\r
# 预览模式\r
python convert_format.py images /path/to/images png --dry-run\r
```\r
\r
## 依赖要求\r
\r
**文件重命名**:\r
- Python 3.6+\r
- 无额外依赖(仅使用标准库)\r
\r
**格式转换**:\r
- Python 3.6+\r
- Pillow: 图片处理 (`pip install Pillow`)\r
- pdf2image: PDF 转图片 (`pip install pdf2image`)\r
- docx2pdf: DOCX 转 PDF (`pip install docx2pdf`)\r
- markdown + weasyprint: Markdown 转 PDF (`pip install markdown weasyprint`)\r
\r
**注意**: pdf2image 需要 Poppler 库在 Windows 上。可以从 https://github.com/oschwartz10612/poppler-windows/releases/ 下载并安装。\r
\r
## 最佳实践\r
\r
1. **使用预览模式**: 在执行批量操作前,先使用 `dry_run=True` 预览结果\r
2. **备份重要文件**: 执行批量重命名或转换前,先备份重要文件\r
3. **检查依赖**: 执行格式转换前,确保已安装所需的 Python 库\r
4. **验证结果**: 执行完成后,检查文件是否符合预期\r
5. **处理冲突**: 脚本会自动跳过会产生命名冲突的重命名操作\r
\r
## 常见问题\r
\r
**Q: 重命名操作可以撤销吗?**\r
A: 重命名操作是不可逆的。建议先使用 `dry_run=True` 预览,确认无误后再执行。\r
\r
**Q: 如何处理嵌套目录中的文件?**\r
A: 当前脚本仅处理指定目录中的文件,不递归处理子目录。如需处理子目录,需要手动遍历。\r
\r
**Q: 图片转换会保持原质量吗?**\r
A: 可以通过 `quality` 参数控制图片质量(1-100),默认为 95。\r
\r
**Q: PDF 转图片需要安装什么?**\r
A: 需要安装 `pdf2image` 库和 Poppler 库。Poppler 在 Windows 上需要单独下载安装。\r
\r
**Q: 支持哪些图片格式?**\r
A: 支持 JPG、JPEG、PNG、WebP、BMP、TIFF 等常见格式。\r
\r
## 资源\r
\r
此技能包含以下可执行脚本:\r
\r
- `scripts/rename_files.py`: 文件重命名工具\r
- `scripts/convert_format.py`: 文件格式转换工具\r
\r
这些脚本可以直接作为 Python 模块导入使用,也可以通过命令行调用。\r
安全使用建议
This package appears to be a straightforward local file-processing tool. Before using it: (1) back up important files and use dry_run mode to preview changes; (2) ensure required Python packages are installed (Pillow, pdf2image, docx2pdf, markdown, weasyprint) and any native dependencies (Poppler on Windows, and Word may be required for docx2pdf on Windows); (3) run it only on directories you intend to modify (it operates on files you point it at and will rename/write files there); (4) note the rename tool prompts for confirmation (unless you only use dry_run), so automated/unattended runs may require adjustment. There are no signs of network exfiltration, hidden endpoints, or requests for credentials.
功能分析
Type: OpenClaw Skill Name: bot-file-processor Version: 1.0.0 The skill bundle provides legitimate file renaming and format conversion utilities using standard Python libraries (Pillow, pdf2image, docx2pdf). The code in scripts/convert_format.py and scripts/rename_files.py is well-structured, includes safety features like dry-run modes and user confirmation prompts, and lacks any indicators of malicious intent, data exfiltration, or unauthorized execution.
能力评估
Purpose & Capability
Name/description, SKILL.md, and included Python scripts all align: the scripts implement batch renaming and format conversion operations described in the README. Required dependencies (Pillow, pdf2image, docx2pdf, markdown, weasyprint) are appropriate for the claimed functionality.
Instruction Scope
SKILL.md instructions and examples only reference local file system paths and the included scripts. The code reads/writes files only at the provided target directories/paths and prompts for user confirmation before performing renames (unless dry_run). There are no instructions to read unrelated system files, environment variables, or transmit data off-host.
Install Mechanism
No install spec provided (instruction-only skill with included scripts). Dependencies are Python packages noted in SKILL.md; there are no downloads from arbitrary URLs or archive extraction steps in the package.
Credentials
The skill declares no required environment variables, no credentials, and no config paths. The code does not access environment variables or secret data. External dependencies (e.g., Poppler for pdf2image or Word for docx2pdf on Windows) are documented in SKILL.md and are proportional to the feature set.
Persistence & Privilege
The skill does not request permanent presence (always:false) and does not attempt to modify other skills or system-wide agent settings. It is a local utility invoked by the user or agent without elevated persistence requirements.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install bot-file-processor
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /bot-file-processor 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Version 1.0.0 of ollie-file-processor - Renamed the skill from "file-processor" to "ollie-file-processor". - No changes detected in functionality or code. - Documentation updated to reflect the new skill name.
元数据
Slug bot-file-processor
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

bot File Processor 是什么?

通用文件处理技能,用于批量重命名和格式转换。当用户需要批量重命名文件(添加前缀/后缀、替换文本、编号重命名、正则表达式重命名)或转换文件格式(图片格式转换、PDF与图片互转、DOCX转PDF、Markdown转PDF)时使用此技能。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 129 次。

如何安装 bot File Processor?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install bot-file-processor」即可一键安装,无需额外配置。

bot File Processor 是免费的吗?

是的,bot File Processor 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

bot File Processor 支持哪些平台?

bot File Processor 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 bot File Processor?

由 ollielin(@ollielin)开发并维护,当前版本 v1.0.0。

💬 留言讨论