Skip to content

/xberg-batch-extraction

Use when extracting from many files at once with shared config, bounded parallelism, per-file overrides, and error recovery. Covers the `batch` command, `--file-configs`, `--max-concurrent`, and output layout.

From plugin
xberg
9.6k7 skills2 commands1 MCP

Claude Code

$ npx -y skills add xberg-io/xberg --skill xberg-batch-extraction --agent claude-code

SKILL.md

xberg-batch-extraction.SKILL.md
description: Use when extracting from many files at once with shared config, bounded parallelism, per-file overrides, and error recovery. Covers the `batch` command, `--file-configs`, `--max-concurrent`, and output layout.
name: xberg-batch-extraction

<!-- AI-RULEZ :: GENERATED FILE — DO NOT EDIT Content-Hash: blake3:324433f2b10c7c9cdc1c06b98c1e427c8cb0ca9ccf034d336e28d49706add520 Source-Hash: blake3:49008ec07dddf974eb0c5783027a34d6be95e37b834da935135b4feece9fe8f8 Schema-Version: v1 -->

Batch extraction

Use this when processing a directory or glob of documents in one pass. `xberg batch` shares one extraction config across every file, runs extractions concurrently, and returns a JSON envelope — failures on individual files do not abort the run.

Basic usage

# Glob expands to many paths; results come back in a JSON envelope (default)
xberg batch *.pdf

# Mixed formats, markdown content for LLM ingestion
xberg batch docs/*.docx --content-format markdown

# Recurse with the shell, then extract
xberg batch $(find ./corpus -name '*.pdf')

`batch` defaults to `--format json` (vs `--format text` for single `extract`). The envelope contains `results`, `total_ms`, `per_file_ms` and, when failures occur, `errors`. Each `results` entry is a full extracted document. One input may produce multiple documents, so do not pair results with inputs by position. `per_file_ms` is aligned with inputs; inspect `errors` for per-input failures.

xberg batch reports/*.pdf \
  | jq '.results[] | {chars: (.content | length), mime: .mime_type}'

Parallelism

`--max-concurrent` caps how many files extract at once. When omitted, the scheduler derives document concurrency from the total thread budget. Lower it on memory-constrained hosts or when OCR/ML models are active, since each in-flight extraction holds its own buffers. Layout-heavy batches are further limited (1 concurrent extraction for all-PDF-layout batches, 2 for mixed layout):

# Cap at 4 concurrent extractions
xberg batch scans/*.pdf --ocr true --max-concurrent 4

`--max-threads` additionally caps *total* internal threads (Rayon, ONNX intra-op, the batch semaphore) for tightly constrained environments:

xberg batch *.pdf --max-concurrent 2 --max-threads 4

Per-file config overrides

A single shared config does not always fit. `--file-configs` points at a JSON file mapping each path to its own override object, merged on top of the shared config for that file only:

{
  "scan.pdf": { "force_ocr": true },
  "report.pdf": { "output_format": "markdown" },
  "data.xlsx": { "output_format": "json" }
}
xberg batch scan.pdf report.pdf data.xlsx --file-configs overrides.json

Keys are file paths (matching the paths passed on the command line); values are per-file extraction config objects in snake_case, the same shape as a config file.

Output layout

For text/toon output with image extraction, `--output-dir` controls where referenced image files (e.g. `image_0.png`) are written; the directory must already exist. JSON output embeds image bytes inline and ignores `--output-dir`.

mkdir -p out/images
xberg batch slides/*.pptx --extract-images true --output-dir out/images --format text

Error recovery

Batch extraction is fault-tolerant per file: one unreadable or corrupt document does not stop the rest. Inspect results for partial content and surfaced errors rather than relying on the process exit code alone. Pair with `--max-concurrent` to avoid exhausting memory when a few large files sit in a big batch.

Shared config

Every `extract` flag also applies to `batch` (OCR, chunking, layout, content format, etc.) and is shared across all files unless a `--file-configs` entry overrides it:

xberg batch invoices/*.pdf \
  --layout --layout-table-model slanet_wireless \
  --content-format markdown --max-concurrent 8

A config file works too and auto-discovers from the cwd upward:

output_format = "markdown"

[ocr]
backend = "tesseract"
language = "eng"
xberg batch corpus/*.pdf --config xberg.toml

Programmatic access

From Python, `extract_batch` takes a list of `ExtractInput`s and returns one envelope whose `results` array holds a document per input:

from xberg import ExtractInput, extract_batch, ExtractionConfig

config = ExtractionConfig(output_format="markdown")

inputs = [ExtractInput(uri=p) for p in ["a.pdf", "b.docx", "c.xlsx"]]
output = await extract_batch(inputs, config)

for doc in output.results:
    print(len(doc.content))

Per-input overrides go on `ExtractInput.config` (a `FileExtractionConfig`). Node.js mirrors this with `extractBatch`; Rust uses `extract_batch(inputs, &config)`. See `references/python-api.md`, `references/nodejs-api.md`, and `references/rust-api.md`.

MCP

When the `xberg` MCP server is registered, prefer the `extract_batch` tool over shelling out — it takes an array of input objects and a config object and returns structured results directly.

Common pitfalls

  • **Default format differs** — `batch` defaults to `--format json`,

`extract` to `--format text`. Set `--format` explicitly if a script depends on one shape.

  • **`--output-dir` must exist** — the CLI does not create it.
  • **Memory blowups** — large batches with OCR/layout active may need an explicit

`--max-concurrent` ceiling.

  • **`--file-configs` path keys** — must match the paths as passed on the

command line, not absolute-resolved variants.

See `references/cli-reference.md` for the full `batch` flag set.

Read more
@xberg-io
Ships withxberg

The fast, precise document-intelligence engine — for every language. Point Xberg at anything — a PDF, a scanned image, a spreadsheet, an audio file, a URL, a whole archive, or a source tree — and get back clean text, tables, metadata, and structured data.

Stars on GitHub

Momentum

stars in total
9.6k
Star history of xberg-io/xberg on GitHub, a chart by star-history.com

Other skills on xberg.

xberg-chunking
Auto-invoked

xberg-chunking

Use when splitting extracted text into chunks for LLM context windows or RAG ingestion. Covers chunk size, overlap,…

@xberg-io@xberg-ioInstall Skill
xberg-extracting-keywords
Auto-invoked

xberg-extracting-keywo…

Use when extracting keywords (YAKE/RAKE) from documents — and, secondarily, when detecting document language or generating…

@xberg-io@xberg-ioInstall Skill
xberg-extracting-tables
Auto-invoked

xberg-extracting-table…

Use when extracting tabular data from PDFs, spreadsheets, or images. Covers layout-aware table detection, table model selection,…

@xberg-io@xberg-ioInstall Skill
xberg-extracting-with-ocr
Auto-invoked

xberg-extracting-with-…

Use when extracting text from scanned PDFs, photographed pages, or images that have no embedded text layer. Covers OCR backends,…

@xberg-io@xberg-ioInstall Skill
xberg-picking-a-format
Auto-invoked

xberg-picking-a-format

Use when choosing an output format for extracted documents — plain text, markdown, djot, HTML, JSON, or DocTags. Maps consumer…

@xberg-io@xberg-ioInstall Skill
xberg
Auto-invoked

xberg

Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using…

@xberg-io@xberg-ioInstall Skill

More skills from other plugins.

paddleocr-doc-parsing

paddleocr-doc-parsing

Use this skill to extract structured Markdown/JSON from PDFs and document images—tables with cell-level precision, formulas as…

paddleocr2mo93k
@paddlepaddle@paddlepaddleInstall Skill
context-loader
Auto-invoked

context-loader

Search memories from earlier Pi sessions in this repository. Use it when earlier work may already explain the code, error,…

mem013d69k
@mem0ai@mem0aiInstall Skill
analyzing-ai-citations

analyzing-ai-citations

Answer AI citation and answer engine optimization (AEO) questions in PostHog: whether AI answer engines (ChatGPT, Claude, and an…

posthog2w41k
@posthog@posthogInstall Skill

Questions about xberg-batch-extraction.

Which coding agents can use xberg-batch-extraction?
xberg-batch-extraction installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.