{"data":{"slug":"github-claude-office-skills-skills-batch-convert-e8c7eee0641b","title":"Batch Convert Documents Between Formats","summary":"Convert multiple files between DOCX, PDF, MD, HTML, XLSX, and PPTX formats with automated processing and format preservation. The deliverable is converted files in the target format, with support for bulk processing and parallel execution.","url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-batch-convert-e8c7eee0641b","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-claude-office-skills-skills-batch-convert-e8c7eee0641b","markdown_url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-batch-convert-e8c7eee0641b.md","download_url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-batch-convert-e8c7eee0641b\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"This skill requires the installation of dependencies such as pdf2docx, markitdown, python-docx, and openpyxl. Some conversions may require external tools like Pandoc or Marp. Complex formatting may be lost during conversion, and large files may take longer to process.","instructions":"---\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n# CLAUDE OFFICE SKILL - Enhanced Metadata v2.0\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n# Basic Information\nname: batch-convert\ndescription: \"Batch convert documents between multiple formats using a unified pipeline\"\nversion: \"1.0\"\nauthor: claude-office-skills\nlicense: MIT\n\n# Categorization\ncategory: conversion\ntags:\n  - batch\n  - conversion\n  - bulk\n  - automation\ndepartment: All\n\n# AI Model Compatibility\nmodels:\n  recommended:\n    - claude-sonnet-4\n    - claude-opus-4\n  compatible:\n    - claude-3-5-sonnet\n    - gpt-4\n    - gpt-4o\n\n# MCP Tools Integration\nmcp:\n  server: office-mcp\n  tools:\n    - batch_convert\n\n# Skill Capabilities\ncapabilities:\n  - bulk_conversion\n  - automation\n\n# Language Support\nlanguages:\n  - en\n  - zh\n---\n\n# Batch Convert Skill\n\n## Overview\n\nThis skill enables batch conversion of documents between multiple formats using a unified pipeline. Convert hundreds of files at once with consistent settings, automatic format detection, and parallel processing for maximum efficiency.\n\n## How to Use\n\n1. Specify the source folder or files\n2. Choose target format(s)\n3. Optionally configure conversion options\n4. I'll process all files with progress tracking\n\n**Example prompts:**\n- \"Convert all PDFs in this folder to Word documents\"\n- \"Batch convert these markdown files to PDF and HTML\"\n- \"Process all Office files and convert to Markdown\"\n- \"Convert this folder of images to a single PDF\"\n\n## Domain Knowledge\n\n### Supported Format Matrix\n\n| From | To: DOCX | To: PDF | To: MD | To: HTML | To: PPTX |\n|------|----------|---------|--------|----------|----------|\n| DOCX | - | \u2705 | \u2705 | \u2705 | - |\n| PDF | \u2705 | - | \u2705 | \u2705 | - |\n| MD | \u2705 | \u2705 | - | \u2705 | \u2705 |\n| HTML | \u2705 | \u2705 | \u2705 | - | - |\n| XLSX | - | \u2705 | \u2705 | \u2705 | - |\n| PPTX | - | \u2705 | \u2705 | \u2705 | - |\n\n### Core Pipeline\n\n```python\nfrom pathlib import Path\nfrom concurrent.futures import ThreadPoolExecutor, as_completed\nimport subprocess\nimport os\n\nclass DocumentConverter:\n    \"\"\"Unified document conversion pipeline.\"\"\"\n    \n    def __init__(self, max_workers=4):\n        self.max_workers = max_workers\n        self.converters = {\n            ('md', 'docx'): self._md_to_docx,\n            ('md', 'pdf'): self._md_to_pdf,\n            ('md', 'html'): self._md_to_html,\n            ('md', 'pptx'): self._md_to_pptx,\n            ('docx', 'pdf'): self._docx_to_pdf,\n            ('docx', 'md'): self._docx_to_md,\n            ('pdf', 'docx'): self._pdf_to_docx,\n            ('pdf', 'md'): self._pdf_to_md,\n            ('xlsx', 'pdf'): self._xlsx_to_pdf,\n            ('xlsx', 'md'): self._xlsx_to_md,\n            ('pptx', 'pdf'): self._pptx_to_pdf,\n            ('pptx', 'md'): self._pptx_to_md,\n            ('html', 'md'): self._html_to_md,\n            ('html', 'pdf'): self._html_to_pdf,\n        }\n    \n    def convert(self, input_path, output_format, output_dir=None):\n        \"\"\"Convert single file to target format.\"\"\"\n        input_path = Path(input_path)\n        input_format = input_path.suffix[1:].lower()\n        \n        if output_dir:\n            output_path = Path(output_dir) \/ f\"{input_path.stem}.{output_format}\"\n        else:\n            output_path = input_path.with_suffix(f\".{output_format}\")\n        \n        converter_key = (input_format, output_format)\n        if converter_key not in self.converters:\n            raise ValueError(f\"Conversion not supported: {input_format} -> {output_format}\")\n        \n        converter = self.converters[converter_key]\n        return converter(input_path, output_path)\n    \n    def batch_convert(self, input_dir, output_format, output_dir=None, \n                      file_pattern=\"*\", recursive=False):\n        \"\"\"Batch convert all matching files.\"\"\"\n        input_path = Path(input_dir)\n        output_path = Path(output_dir) if output_dir else input_path \/ \"converted\"\n        output_path.mkdir(exist_ok=True)\n        \n        # Find files\n        if recursive:\n            files = list(input_path.rglob(file_pattern))\n        else:\n            files = list(input_path.glob(file_pattern))\n        \n        # Filter to supported formats\n        supported_ext = ['.md', '.docx', '.pdf', '.xlsx', '.pptx', '.html']\n        files = [f for f in files if f.suffix.lower() in supported_ext]\n        \n        results = []\n        \n        with ThreadPoolExecutor(max_workers=self.max_workers) as executor:\n            future_to_file = {\n                executor.submit(self.convert, f, output_format, output_path): f\n                for f in files\n            }\n            \n            for future in as_completed(future_to_file):\n                file = future_to_file[future]\n                try:\n                    result = future.result()\n                    results.append({'file': str(file), 'status': 'success', 'output': str(result)})\n                except Exception as e:\n                    results.append({'file': str(file), 'status': 'error', 'error': str(e)})\n        \n        return results\n```\n\n### Converter Implementations\n\n```python\n# Markdown conversions (using Pandoc)\ndef _md_to_docx(self, input_path, output_path):\n    subprocess.run(['pandoc', str(input_path), '-o', str(output_path)], check=True)\n    return output_path\n\ndef _md_to_pdf(self, input_path, output_path):\n    subprocess.run(['pandoc', str(input_path), '-o', str(output_path)], check=True)\n    return output_path\n\ndef _md_to_html(self, input_path, output_path):\n    subprocess.run(['pandoc', str(input_path), '-s', '-o', str(output_path)], check=True)\n    return output_path\n\ndef _md_to_pptx(self, input_path, output_path):\n    subprocess.run(['marp', str(input_path), '-o', str(output_path)], check=True)\n    return output_path\n\n# Office to Markdown (using markitdown)\ndef _docx_to_md(self, input_path, output_path):\n    from markitdown import MarkItDown\n    md = MarkItDown()\n    result = md.convert(str(input_path))\n    with open(output_path, 'w') as f:\n        f.write(result.text_content)\n    return output_path\n\ndef _xlsx_to_md(self, input_path, output_path):\n    from markitdown import MarkItDown\n    md = MarkItDown()\n    result = md.convert(str(input_path))\n    with open(output_path, 'w') as f:\n        f.write(result.text_content)\n    return output_path\n\ndef _pptx_to_md(self, input_path, output_path):\n    from markitdown import MarkItDown\n    md = MarkItDown()\n    result = md.convert(str(input_path))\n    with open(output_path, 'w') as f:\n        f.write(result.text_content)\n    return output_path\n\n# PDF conversions\ndef _pdf_to_docx(self, input_path, output_path):\n    from pdf2docx import Converter\n    cv = Converter(str(input_path))\n    cv.convert(str(output_path))\n    cv.close()\n    return output_path\n\ndef _pdf_to_md(self, input_path, output_path):\n    from markitdown import MarkItDown\n    md = MarkItDown()\n    result = md.convert(str(input_path))\n    with open(output_path, 'w') as f:\n        f.write(result.text_content)\n    return output_path\n\n# Office to PDF (using LibreOffice)\ndef _docx_to_pdf(self, input_path, output_path):\n    subprocess.run([\n        'soffice', '--headless', '--convert-to', 'pdf',\n        '--outdir', str(output_path.parent), str(input_path)\n    ], check=True)\n    return output_path\n\ndef _xlsx_to_pdf(self, input_path, output_path):\n    subprocess.run([\n        'soffice', '--headless', '--convert-to', 'pdf',\n        '--outdir', str(output_path.parent), str(input_path)\n    ], check=True)\n    return output_path\n\ndef _pptx_to_pdf(self, input_path, output_path):\n    subprocess.run([\n        'soffice', '--headless', '--convert-to', 'pdf',\n        '--outdir', str(output_path.parent), str(input_path)\n    ], check=True)\n    return output_path\n```\n\n### Progress Tracking\n\n```python\nfrom tqdm import tqdm\n\ndef batch_convert_with_progress(converter, input_dir, output_format, output_dir=None):\n    \"\"\"Batch convert with progress bar.\"\"\"\n    input_path = Path(input_dir)\n    files = list(input_path.glob('*'))\n    \n    results = []\n    for file in tqdm(files, desc=f\"Converting to {output_format}\"):\n        try:\n            result = converter.convert(file, output_format, output_dir)\n            results.append({'file': str(file), 'status': 'success'})\n        except Exception as e:\n            results.append({'file': str(file), 'status': 'error', 'error': str(e)})\n    \n    return results\n```\n\n## Best Practices\n\n1. **Test Sample First**: Convert a few files before batch processing\n2. **Check Disk Space**: Ensure sufficient space for output\n3. **Use Parallel Processing**: Speed up with multiple workers\n4. **Handle Errors Gracefully**: Log failures, continue processing\n5. **Verify Output**: Spot-check converted files\n\n## Common Patterns\n\n### Format Detection Pipeline\n```python\ndef detect_and_convert(file_path, target_format):\n    \"\"\"Automatically detect format and convert.\"\"\"\n    import mimetypes\n    \n    mime_type, _ = mimetypes.guess_type(str(file_path))\n    \n    format_map = {\n        'application\/pdf': 'pdf',\n        'application\/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx',\n        'application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'xlsx',\n        'application\/vnd.openxmlformats-officedocument.presentationml.presentation': 'pptx',\n        'text\/markdown': 'md',\n        'text\/html': 'html',\n    }\n    \n    source_format = format_map.get(mime_type, Path(file_path).suffix[1:])\n    \n    converter = DocumentConverter()\n    return converter.convert(file_path, target_format)\n```\n\n### Multi-Format Output\n```python\ndef convert_to_multiple_formats(input_file, output_formats, output_dir):\n    \"\"\"Convert one file to multiple formats.\"\"\"\n    converter = DocumentConverter()\n    results = {}\n    \n    for fmt in output_formats:\n        try:\n            output = converter.convert(input_file, fmt, output_dir)\n            results[fmt] = {'status': 'success', 'path': str(output)}\n        except Exception as e:\n            results[fmt] = {'status': 'error', 'error': str(e)}\n    \n    return results\n\n# Convert README to multiple formats\nresults = convert_to_multiple_formats(\n    'README.md',\n    ['docx', 'pdf', 'html'],\n    '.\/exports'\n)\n```\n\n## Examples\n\n### Example 1: Documentation Export\n```python\nfrom pathlib import Path\nimport json\n\ndef export_documentation(docs_dir, export_dir):\n    \"\"\"Export all documentation to multiple formats.\"\"\"\n    \n    converter = DocumentConverter(max_workers=8)\n    docs_path = Path(docs_dir)\n    export_path = Path(export_dir)\n    \n    # Create format directories\n    for fmt in ['pdf', 'docx', 'html']:\n        (export_path \/ fmt).mkdir(parents=True, exist_ok=True)\n    \n    all_results = {}\n    \n    # Find all markdown files\n    md_files = list(docs_path.rglob('*.md'))\n    \n    for md_file in md_files:\n        file_results = {}\n        \n        for fmt in ['pdf', 'docx', 'html']:\n            output_dir = export_path \/ fmt\n            try:\n                output = converter.convert(md_file, fmt, output_dir)\n                file_results[fmt] = 'success'\n            except Exception as e:\n                file_results[fmt] = f'error: {e}'\n        \n        all_results[str(md_file)] = file_results\n        print(f\"Processed: {md_file.name}\")\n    \n    # Save report\n    with open(export_path \/ 'export_report.json', 'w') as f:\n        json.dump(all_results, f, indent=2)\n    \n    return all_results\n\nresults = export_documentation('.\/docs', '.\/exports')\n```\n\n### Example 2: Legacy Document Migration\n```python\ndef migrate_legacy_docs(source_dir, target_dir):\n    \"\"\"Migrate legacy documents to modern formats.\"\"\"\n    \n    converter = DocumentConverter(max_workers=4)\n    \n    # Migration rules\n    migrations = [\n        ('*.doc', 'docx'),   # Old Word to new\n        ('*.xls', 'xlsx'),   # Old Excel to new\n        ('*.ppt', 'pptx'),   # Old PowerPoint to new\n        ('*.rtf', 'docx'),   # RTF to Word\n    ]\n    \n    source_path = Path(source_dir)\n    target_path = Path(target_dir)\n    target_path.mkdir(exist_ok=True)\n    \n    total_migrated = 0\n    errors = []\n    \n    for pattern, target_format in migrations:\n        files = list(source_path.glob(pattern))\n        \n        for file in files:\n            try:\n                # Use LibreOffice for legacy formats\n                subprocess.run([\n                    'soffice', '--headless',\n                    '--convert-to', target_format,\n                    '--outdir', str(target_path),\n                    str(file)\n                ], check=True)\n                \n                total_migrated += 1\n                print(f\"Migrated: {file.name}\")\n                \n            except Exception as e:\n                errors.append({'file': str(file), 'error': str(e)})\n    \n    print(f\"\\nMigration complete: {total_migrated} files\")\n    print(f\"Errors: {len(errors)}\")\n    \n    return {'migrated': total_migrated, 'errors': errors}\n```\n\n### Example 3: Report Generation Pipeline\n```python\ndef generate_reports_pipeline(data_files, template_dir, output_dir):\n    \"\"\"Generate reports from data files using templates.\"\"\"\n    \n    from datetime import datetime\n    \n    converter = DocumentConverter()\n    output_path = Path(output_dir)\n    output_path.mkdir(exist_ok=True)\n    \n    timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')\n    \n    reports = []\n    \n    for data_file in data_files:\n        # Load data\n        data_path = Path(data_file)\n        \n        # Generate markdown report\n        md_content = f\"\"\"---\ntitle: Report - {data_path.stem}\ndate: {datetime.now().strftime('%Y-%m-%d')}\n---\n\n# {data_path.stem} Report\n\nGenerated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n## Data Summary\n\n\"\"\"\n        \n        # Add data content (simplified)\n        if data_path.suffix == '.xlsx':\n            from markitdown import MarkItDown\n            md = MarkItDown()\n            result = md.convert(str(data_path))\n            md_content += result.text_content\n        \n        # Save markdown\n        md_file = output_path \/ f\"{data_path.stem}_{timestamp}.md\"\n        with open(md_file, 'w') as f:\n            f.write(md_content)\n        \n        # Convert to PDF and DOCX\n        for fmt in ['pdf', 'docx']:\n            try:\n                output = converter.convert(md_file, fmt, output_path)\n                reports.append({'source': str(data_file), 'output': str(output), 'format': fmt})\n            except Exception as e:\n                print(f\"Error converting {data_file} to {fmt}: {e}\")\n    \n    return reports\n```\n\n## Limitations\n\n- Some format combinations not supported\n- Complex formatting may be lost in conversion\n- Large files may require more time\n- Some conversions need external tools (LibreOffice, Pandoc)\n- Quality varies by source document complexity\n\n## Installation\n\n```bash\n# Core dependencies\npip install pdf2docx markitdown python-docx openpyxl\n\n# Pandoc (for MD conversions)\nbrew install pandoc  # macOS\napt install pandoc   # Ubuntu\n\n# Marp (for PPTX)\nnpm install -g @marp-team\/marp-cli\n\n# LibreOffice (for Office formats)\nbrew install libreoffice  # macOS\napt install libreoffice   # Ubuntu\n```\n\n## Resources\n\n- [Pandoc Documentation](https:\/\/pandoc.org\/MANUAL.html)\n- [markitdown GitHub](https:\/\/github.com\/microsoft\/markitdown)\n- [pdf2docx Documentation](https:\/\/pdf2docx.readthedocs.io\/)\n- [LibreOffice CLI](https:\/\/help.libreoffice.org\/latest\/en-US\/text\/shared\/guide\/start_parameters.html)\n","use_cases":["Convert all PDFs in a folder to Word documents","Batch convert markdown files to PDF and HTML","Process Office files and convert to Markdown","Convert a folder of images to a single PDF"],"limitations":[],"compatibility":[],"setup_tip":"```bash\n# Core dependencies\npip install pdf2docx markitdown python-docx openpyxl\n\n# Pandoc (for MD conversions)\nbrew install pandoc  # macOS\napt install pandoc   # Ubuntu\n\n# Marp (for PPTX)\nnpm install -g @marp-team\/marp-cli\n\n# LibreOffice (for Office formats)\nbrew install libreoffice  # macOS\napt install libreoffice   # Ubuntu\n```","sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/claude-office-skills\/skills\/blob\/9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11\/batch-convert\/SKILL.md","source_commit":"9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11","license":"MIT","version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T12:54:25.000000Z","updated_at":"2026-11-22T11:17:33.000000Z","seo_title":"Batch Convert Documents Between Formats","seo_description":"Convert multiple files between DOCX, PDF, MD, HTML, XLSX, and PPTX formats with automated processing and format preservation.","seo_keywords":["batch document conversion","multi-format file conversion","automated file conversion","convert multiple files","convert PDF to Word","convert markdown to PDF"]}}