Validate PowerPoint files using python-pptx when standard file readers fail
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-pptx-file-validation-33b6bcfe43bd ,按照其中的说明把「pptx-file-validation」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
This skill provides a reliable method to validate PowerPoint (.pptx) files when the built-in read_file function fails or returns insufficient information.
read_file fails to read a .pptx fileAttempt to read the PowerPoint file using read_file. If it fails, returns garbled content, or doesn't provide the structural information you need, proceed to Step 2.
Execute a Python script using run_shell with the python-pptx library to inspect the presentation:
python3 -c "
from pptx import Presentation
prs = Presentation('path/to/file.pptx')
print(f'Total slides: {len(prs.slides)}')
for i, slide in enumerate(prs.slides, 1):
print(f'Slide {i}: {slide.shapes.title.text if slide.shapes.title else \"[No Title]\"}')
"
Analyze the output to verify:
Document the validation findings, including:
# In your agent workflow
run_shell(command="python3 -c \"from pptx import Presentation; prs = Presentation('output.pptx'); print(f'Slides: {len(prs.slides)}'); [print(f'{i}: {s.shapes.title.text}') for i, s in enumerate(prs.slides, 1) if s.shapes.title]\"")
Ensure python-pptx is available in the environment:
pip install python-pptx