Bulk-create entities

Import a directory of Markdown runbooks (or notes, knowledge docs) into Veirox entities in a single script.

Prerequisites

  • CLI authenticated with a key that has entities:write scope.
  • A directory of .md files (e.g. ./runbooks/).

Steps

#!/usr/bin/env bash
# bulk-import.sh
KIND="${KIND:-runbook}"
DIR="${DIR:-./runbooks}"

for file in "$DIR"/*.md; do
  slug="$(basename "$file" .md)"
  title="$(head -1 "$file" | sed 's/^# //')"
  echo "Creating: $slug ($title)"
  veirox entity create     --kind "$KIND"     --slug "$slug"     --title "$title"     --body-file "$file"
done
KIND=runbook DIR=./runbooks bash bulk-import.sh

Common pitfalls

  • Duplicate slugs: create fails if a slug already exists. Use veirox entity update for subsequent syncs (see the git hook recipe).
  • Title detection: the head -1 trick assumes the first line is an H1. Adjust for your file format.

See also