Skip to content
Back to skills

10 Batch Conversion Scripts

ASecurity

Sub-skill of pandoc: 10. Batch Conversion Scripts.

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
toolspythongobash

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add vamseeachanta/workspace-hub --skill 10-batch-conversion-scripts --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 10 Batch Conversion Scripts?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 10 Batch Conversion Scripts
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vamseeachanta-10-batch-conversion-scripts/badge)](https://www.skillsdirectory.com/skills/vamseeachanta-10-batch-conversion-scripts)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pandoc-10-batch-conversion-scripts
description: 'Sub-skill of pandoc: 10. Batch Conversion Scripts.'
version: 1.0.0
category: development
type: reference
scripts_exempt: true
---

# 10. Batch Conversion Scripts

## 10. Batch Conversion Scripts


```bash
#!/bin/bash
# scripts/batch-convert.sh
# Convert all Markdown files to PDF

set -euo pipefail

# Configuration
INPUT_DIR="${1:-./docs}"
OUTPUT_DIR="${2:-./output}"
TEMPLATE="${3:-}"

# Create output directory
mkdir -p "$OUTPUT_DIR"

# Find and convert all markdown files
find "$INPUT_DIR" -name "*.md" -type f | while read -r file; do
    # Get relative path and create output path
    relative="${file#$INPUT_DIR/}"
    output_file="$OUTPUT_DIR/${relative%.md}.pdf"
    output_dir=$(dirname "$output_file")

    # Create output subdirectory
    mkdir -p "$output_dir"

    echo "Converting: $file -> $output_file"

    # Build pandoc command
    cmd=(pandoc "$file" -o "$output_file"
        --pdf-engine=xelatex
        --toc
        --number-sections
        --highlight-style=tango)

    # Add template if specified
    if [[ -n "$TEMPLATE" ]]; then
        cmd+=(--template="$TEMPLATE")
    fi

    # Execute conversion
    "${cmd[@]}"
done

echo "Batch conversion complete!"
echo "Output: $OUTPUT_DIR"
```

```bash
#!/bin/bash
# scripts/convert-to-all-formats.sh
# Convert a document to multiple formats

set -euo pipefail

INPUT_FILE="${1:?Usage: $0 <input.md>}"
BASE_NAME="${INPUT_FILE%.md}"

echo "Converting $INPUT_FILE to multiple formats..."

# PDF
echo "  -> PDF"
pandoc "$INPUT_FILE" -o "${BASE_NAME}.pdf" \
    --pdf-engine=xelatex \
    --toc \
    --number-sections

# DOCX
echo "  -> DOCX"
pandoc "$INPUT_FILE" -o "${BASE_NAME}.docx" \
    --toc

# HTML
echo "  -> HTML"
pandoc "$INPUT_FILE" -o "${BASE_NAME}.html" \
    --standalone \
    --toc \
    --embed-resources

# LaTeX
echo "  -> LaTeX"
pandoc "$INPUT_FILE" -o "${BASE_NAME}.tex"

# EPUB
echo "  -> EPUB"
pandoc "$INPUT_FILE" -o "${BASE_NAME}.epub" \
    --toc

echo "Done! Created:"
ls -la "${BASE_NAME}".*
```

```python
#!/usr/bin/env python3
"""
scripts/smart_convert.py
Smart document converter with configuration file support.
"""

import subprocess
import sys
from pathlib import Path
import yaml


def load_config(config_path: Path) -> dict:
    """Load conversion configuration from YAML."""
    with open(config_path) as f:
        return yaml.safe_load(f)


def convert_document(
    input_file: Path,
    output_file: Path,
    config: dict
) -> bool:
    """Convert a single document using pandoc."""
    cmd = ['pandoc', str(input_file), '-o', str(output_file)]

    # Add common options
    if config.get('toc'):
        cmd.append('--toc')
        if toc_depth := config.get('toc_depth'):
            cmd.extend(['--toc-depth', str(toc_depth)])

    if config.get('number_sections'):
        cmd.append('--number-sections')

    if template := config.get('template'):
        cmd.extend(['--template', template])

    if pdf_engine := config.get('pdf_engine'):
        cmd.extend(['--pdf-engine', pdf_engine])

    if highlight := config.get('highlight_style'):
        cmd.extend(['--highlight-style', highlight])

    if bibliography := config.get('bibliography'):
        cmd.append('--citeproc')
        cmd.extend(['--bibliography', bibliography])

    if csl := config.get('csl'):
        cmd.extend(['--csl', csl])

    # Add variables
    for key, value in config.get('variables', {}).items():
        cmd.extend(['-V', f'{key}={value}'])

    # Add filters
    for filter_name in config.get('filters', []):
        if filter_name.endswith('.lua'):
            cmd.extend(['--lua-filter', filter_name])
        else:
            cmd.extend(['--filter', filter_name])

    print(f"Running: {' '.join(cmd)}")

    result = subprocess.run(cmd, capture_output=True, text=True)

    if result.returncode != 0:
        print(f"Error: {result.stderr}", file=sys.stderr)
        return False

    return True


def main():
    if len(sys.argv) < 3:
        print(f"Usage: {sys.argv[0]} <input.md> <output.pdf> [config.yaml]")
        sys.exit(1)

    input_file = Path(sys.argv[1])
    output_file = Path(sys.argv[2])
    config_file = Path(sys.argv[3]) if len(sys.argv) > 3 else None

    config = {}
    if config_file and config_file.exists():
        config = load_config(config_file)

    success = convert_document(input_file, output_file, config)
    sys.exit(0 if success else 1)


if __name__ == '__main__':
    main()

*Content truncated — see parent skill for full reference.*

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.