batch-label
Overview
Generates labels for multiple Snipe-IT assets in a single batch. Fetches asset data from the Snipe-IT API, creates labels via the label-service, downloads print-ready PNGs, and optionally sends them to the Brother PT-D610BT printer. Supports filtering by asset ID, range, location, or category.
Usage
python scripts/batch-label.py [ASSET_IDS...] [OPTIONS]
Arguments
| Argument | Description |
|---|---|
ASSET_IDS | Snipe-IT hardware IDs -- individual (76 81), ranges (50-76), or omit with --all |
Options
| Option | Description | Default |
|---|---|---|
--all | Process all hardware assets | -- |
--location ID | Filter by Snipe-IT location ID | -- |
--category NAME | Filter by category name (partial match) | -- |
--skip-existing | Skip assets that already have active labels | -- |
--dry-run | Show plan without making changes | -- |
--print | Send to Brother PT-D610BT after download | -- |
--output-dir DIR | Output directory for PNGs | labels/ |
--label-url URL | Label service base URL | http://localhost:8100 |
Prerequisites
- Repo: snipeit-asset-management
- Install:
pip install requests Pillow - Environment:
SNIPEIT_TOKEN,LABEL_SERVICE_API_KEY - Services: Label-service running (
docker compose up -dinsrc/label-service/) - Printer: Brother PT-D610BT with b-PAC SDK v3.4+ (for
--print)
Examples
Generate labels for specific assets
python scripts/batch-label.py 76 81 163
Generate labels for a range
python scripts/batch-label.py 50-76
Dry run for all assets in a location
python scripts/batch-label.py --location 2 --dry-run
Generate and print, skipping existing
python scripts/batch-label.py --all --skip-existing --print
Output
PNG files saved to labels/ directory, named by asset tag (e.g., ASSET-0050.png). Summary report printed to console showing created, skipped, and failed counts.