wps-batch-convert — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited wps-batch-convert (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
一个文件夹 → 全部转换 → 输出到目标文件夹。
wps-pdf-extractwps-pdf-merge-split| 源格式 | 目标格式 | 工具 |
|---|---|---|
| .docx | python-docx + reportlab 或 WPS CLI | |
| .docx | .txt | python-docx |
| .xlsx | .csv | openpyxl |
| .csv | .xlsx | openpyxl |
| .pptx | python-pptx + WPS CLI | |
| .md | .docx | markdown + python-docx |
| .txt | .docx | python-docx |
from docx import Document
from openpyxl import load_workbook
import csv
import os
import glob as glob_mod
import subprocess
class BatchConverter:
"""批量格式转换器"""
@staticmethod
def docx_to_txt(docx_path, output_path=None):
"""Word转纯文本"""
doc = Document(docx_path)
text = '\n'.join(para.text for para in doc.paragraphs)
if not output_path:
output_path = os.path.splitext(docx_path)[0] + '.txt'
with open(output_path, 'w', encoding='utf-8') as f:
f.write(text)
return output_path
@staticmethod
def xlsx_to_csv(xlsx_path, output_path=None, sheet_name=None):
"""Excel转CSV"""
wb = load_workbook(xlsx_path, read_only=True)
ws = wb[sheet_name] if sheet_name else wb.active
if not output_path:
output_path = os.path.splitext(xlsx_path)[0] + '.csv'
with open(output_path, 'w', newline='', encoding='utf-8-sig') as f:
writer = csv.writer(f)
for row in ws.iter_rows(values_only=True):
writer.writerow(row)
wb.close()
return output_path
@staticmethod
def csv_to_xlsx(csv_path, output_path=None):
"""CSV转Excel"""
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill
wb = Workbook()
ws = wb.active
with open(csv_path, 'r', encoding='utf-8-sig') as f:
reader = csv.reader(f)
for row_idx, row in enumerate(reader, 1):
for col_idx, val in enumerate(row, 1):
ws.cell(row=row_idx, column=col_idx, value=val)
if row_idx == 1:
for col_idx in range(1, len(row) + 1):
ws.cell(row=1, column=col_idx).font = Font(bold=True)
if not output_path:
output_path = os.path.splitext(csv_path)[0] + '.xlsx'
wb.save(output_path)
return output_path
@staticmethod
def md_to_docx(md_path, output_path=None):
"""Markdown转Word"""
doc = Document()
with open(md_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.rstrip('\n')
if line.startswith('# '):
doc.add_heading(line[2:], level=1)
elif line.startswith('## '):
doc.add_heading(line[3:], level=2)
elif line.startswith('### '):
doc.add_heading(line[4:], level=3)
elif line.startswith('- '):
doc.add_paragraph(line[2:], style='List Bullet')
elif line.strip():
doc.add_paragraph(line)
if not output_path:
output_path = os.path.splitext(md_path)[0] + '.docx'
doc.save(output_path)
return output_path
@staticmethod
def batch_convert(source_dir, source_ext, target_ext, output_dir=None):
"""批量转换文件夹"""
if not output_dir:
output_dir = os.path.join(source_dir, f'converted_{target_ext}')
os.makedirs(output_dir, exist_ok=True)
converter_map = {
('.docx', '.txt'): BatchConverter.docx_to_txt,
('.xlsx', '.csv'): BatchConverter.xlsx_to_csv,
('.csv', '.xlsx'): BatchConverter.csv_to_xlsx,
('.md', '.docx'): BatchConverter.md_to_docx,
}
func = converter_map.get((source_ext, target_ext))
if not func:
raise ValueError(f'不支持 {source_ext} → {target_ext} 转换')
files = glob_mod.glob(os.path.join(source_dir, f'*{source_ext}'))
results = []
for f in files:
basename = os.path.splitext(os.path.basename(f))[0]
out = os.path.join(output_dir, f'{basename}{target_ext}')
func(f, out)
results.append(out)
return results# 批量Word转文本
/wps-batch-convert 把docs文件夹里所有docx转成txt
# Excel转CSV
/wps-batch-convert 把所有xlsx导出为csv
# Markdown转Word
/wps-batch-convert 把notes.md转成Word文档
# 批量处理
/wps-batch-convert reports文件夹里的所有csv转成xlsx~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.