Skip to content
Skills Library
Documents & office · Conversion & formats

xberg-batch-extraction

/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.

Repository
xberg ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
10
Scripts
0
HTML comments
1
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • SKILL.md zawiera komentarze HTML (1). Nie widać ich w podglądzie Markdown, a model je czyta.

What it does and when to use it

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.

Original author 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.

How it works

  1. Basic usage
  2. Parallelism
  3. Per-file config overrides
  4. Output layout
  5. Error recovery
  6. Shared config
  7. Programmatic access
  8. MCP
  9. Common pitfalls
Original SKILL.md headings · 167 lines, 724 words
SKILL.md preview
---
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:934f7e3903a85762c6a94f533fc47d534e94d3274b6a2cd147fa8bda13a6b03a
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

```bash
# 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.

```bash
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):

```bash
# 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:

```bash
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:

```json
{
  "scan.pdf": { "force_ocr": true },
  "report.pdf": { "output_format": "markdown" },
  "data.xlsx": { "output_format": "json" }
}
```

```bash
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`.

```bash
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:

```bash
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:

```toml
output_format = "markdown"

[ocr]
backend = "tesseract"
language = "eng"
```

```bash
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:

```python
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.
Files in this package (10)
  • SKILL.md 5 KB
  • index.md 1 KB
  • references/advanced-features.md 18 KB
  • references/cli-reference.md 12 KB
  • references/configuration.md 33 KB
  • references/nodejs-api.md 13 KB
  • references/other-bindings.md 9 KB
  • references/python-api.md 31 KB
  • references/rust-api.md 12 KB
  • references/supported-formats.md 20 KB

Versions

RepositoryScoreLicence
This page · xberg-io/xberg100MIT
xberg-io/xberg84MIT

Identical content appears in 16 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 4f85f5c41757 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 84xberg
    Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg. Use when writing code that calls Xberg APIs in Python, Node.js/TypeScript, Rust, or CLI. Covers installation, extraction (sync/async),…
  • 100xberg
    Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg. Use when writing code that calls Xberg APIs in Python, Node.js/TypeScript, Rust, or CLI. Covers installation, extraction (sync/async),…
  • 100xberg-extracting-tables
    Use when extracting tabular data from PDFs, spreadsheets, or images. Covers layout-aware table detection, table model selection, output formats (markdown / JSON cells), and known limits.
  • 100batch-file-processor
    Process batch file processor operations. Auto-activating skill for Business Automation. Triggers on: batch file processor, batch file processor Part of the Business Automation skill category. Use when working with batch file processor functionality. Trigger with phrases like…
  • 100batch-processor
    Process multiple documents in bulk with parallel execution. Use when a user asks to batch process files, convert many documents at once, run parallel file operations, bulk rename, bulk transform, or process a directory of files concurrently. Covers parallel execution, error…
  • 100pdf-extractor
    This skill should be used when the user asks to "extract text from PDF", "convert PDF to text", "parse PDF", "read PDF contents", "extract data from documents", "batch PDF extraction", "PDF to markdown", "OCR PDF", "get text from PDF files", "I have a PDF", "can you read this…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.