Convert PDF, DOC, DOCX, and PPTX office documents to Markdown, supporting legacy .doc files with text extraction and basic formatting preservation.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install office-to-md-v2或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install office-to-md-v2⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/office-to-md-v2/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
Convert office documents (PDF, DOC, DOCX, PPTX) to Markdown format. This skill uses the word-extractor library for .doc support and provides full OpenClaw integration.
cp -r /root/.openclaw/workspace/office-to-md-v2/office-to-md /path/to/your/workspace/
cd /path/to/your/workspace/office-to-md
npm install
pip3 install python-pptx
// Convert any supported document
const result = await exec(
'node /path/to/office-to-md/openclaw-skill.js /path/to/document.doc',
{ workdir: '/path/to/workspace', timeout: 60000 }
);
if (result.exitCode === 0) {
console.log('✅ Document converted successfully');
// Output file: /path/to/document.md
} else {
console.error('❌ Conversion failed:', result.stderr);
}
// Import the converter
const { convertOfficeToMarkdown } = require('/path/to/office-to-md/openclaw-skill.js');
// Convert document
const conversionResult = await convertOfficeToMarkdown('/path/to/document.pdf');
if (conversionResult.success) {
console.log(`Output: ${conversionResult.outputPath}`);
console.log(`Preview: ${conversionResult.preview}`);
} else {
console.error(`Error: ${conversionResult.error}`);
}
async function convertDocumentToMarkdown(filePath) {
// Validate file exists
try {
await read(filePath);
} catch (error) {
return { success: false, error: `File not found: ${filePath}` };
}
// Check file extension
const ext = filePath.toLowerCase().slice(-5);
const supported = ['.pdf', '.doc', '.docx', '.pptx'];
if (!supported.some(s => ext.endsWith(s))) {
return {
success: false,
error: `Unsupported file type. Supported: ${supported.join(', ')}`
};
}
// Convert using the skill
const cmd = `node /path/to/office-to-md/openclaw-skill.js "${filePath}"`;
const result = await exec(cmd, {
workdir: '/path/to/workspace',
timeout: 120000 // 2 minutes for large files
});
if (result.exitCode === 0) {
const outputPath = filePath.replace(/\.[^/.]+$/, '.md');
return {
success: true,
outputPath: outputPath,
message: `Converted to: ${outputPath}`
};
} else {
return {
success: false,
error: result.stderr || 'Conversion failed'
};
}
}
// Usage example
const result = await convertDocumentToMarkdown('/path/to/document.doc');
if (result.success) {
const markdown = await read(result.outputPath);
console.log(markdown.substring(0, 1000));
}
// Convert a .doc file and analyze its content
const docPath = '/path/to/document.doc';
const convertResult = await exec(
`node /path/to/office-to-md/openclaw-skill.js "${docPath}"`,
{ workdir: '/path/to/workspace' }
);
if (convertResult.exitCode === 0) {
const mdPath = docPath.replace('.doc', '.md');
const content = await read(mdPath);
// Analyze the content
const wordCount = content.split(/\s+/).length;
const lines = content.split('\n').length;
const hasChinese = /[\u4e00-\u9fff]/.test(content);
console.log(`Document analysis:`);
console.log(`- Word count: ${wordCount}`);
console.log(`- Lines: ${lines}`);
console.log(`- Contains Chinese: ${hasChinese}`);
console.log(`- Preview: ${content.substring(0, 200)}...`);
}
// Convert multiple documents of different formats
const documents = [
'/path/to/report.pdf',
'/path/to/legacy.doc',
'/path/to/modern.docx',
'/path/to/presentation.pptx'
];
const results = [];
for (const doc of documents) {
console.log(`Converting ${doc}...`);
const result = await exec(
`node /path/to/office-to-md/openclaw-skill.js "${doc}"`,
{ workdir: '/path/to/workspace', timeout: 90000 }
);
const success = result.exitCode === 0;
results.push({
file: doc,
success: success,
error: success ? null : result.stderr
});
console.log(success ? '✅ Success' : '❌ Failed');
}
// Summary
const successful = results.filter(r => r.success).length;
console.log(`\nConversion summary: ${successful}/${results.length} successful`);
Returns a Promise that resolves to:
{
success: boolean,
outputPath?: string,
markdown?: string,
preview?: string,
fileType?: string,
message?: string,
stats?: {
lines: number,
characters: number,
words: number
},
error?: string,
stack?: string
}
```bash node --max-old-space-size=4096 openclaw-skill.js large-file.doc ```
- Check file path and permissions - Use absolute paths for reliability
- Ensure file has correct extension - Check if file is actually the claimed format
- The file may be corrupted or in an unusual format - Try opening in Word and saving as .docx first
- word-extractor should handle Chinese encoding automatically - If issues persist, the file may use unusual encoding
- Increase timeout for large files - Check system resources
Enable debug logging by setting environment variable:
DEBUG=office-to-md node openclaw-skill.js document.doc
This skill is provided as-is. The underlying libraries have their own licenses:
安装 Office To Md V2 后,可以对 AI 说这些话来触发它
Help me get started with Office To Md V2
Explains what Office To Md V2 does, walks through the setup, and runs a quick demo based on your current project
Use Office To Md V2 to convert PDF, DOC, DOCX, and PPTX office documents to Markdown, supp...
Invokes Office To Md V2 with the right parameters and returns the result directly in the conversation
What can I do with Office To Md V2 in my documents & notes workflow?
Lists the top use cases for Office To Md V2, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/office-to-md-v2/ 目录(个人级,所有项目可用),或 .claude/skills/office-to-md-v2/(项目级)。重启 AI 客户端后,用 /office-to-md-v2 主动调用,或让 AI 根据上下文自动发现并使用。
Office To Md V2 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Office To Md V2 可免费安装使用。请查阅仓库了解许可证信息。
Convert PDF, DOC, DOCX, and PPTX office documents to Markdown, supporting legacy .doc files with text extraction and basic formatting preservation.
Office To Md V2 属于「Documents & Notes」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my documents & notes tasks using Office To Md V2
Identifies repetitive steps in your workflow and sets up Office To Md V2 to handle them automatically