Scripting & Automation
openrom-core is designed to be the only thing your scripts need to call. This
page collects recipes that are known to work.
Convert a library
Section titled “Convert a library”#!/usr/bin/env bashset -euo pipefail
SRC="/roms/ps2"DST="/roms/ps2-chd"
openrom-core \ --folder "$SRC" \ --output "$DST" \ --format CHD \ --compression Max \ --verify--folder is non-recursive; loop over subdirectories when your collection is
organised by system:
find /roms -mindepth 1 -maxdepth 1 -type d | while read -r system; do name="$(basename "$system")" openrom-core --folder "$system" --output "/out/$name" --format CHD --verifydoneBuild a hash manifest
Section titled “Build a hash manifest”openrom-core --json --hash "game.iso" | jq -r '[.crc32, .sha1, .sha256, input_filename] | @tsv'For a folder, collect one JSON object per file:
: > manifest.jsonlfor f in /roms/ps1/*.bin; do openrom-core --json --hash "$f" | jq -c . >> manifest.jsonldoneThe manifest becomes your integrity baseline. Re-run it later and diff to detect bit rot.
Verify an archive without converting
Section titled “Verify an archive without converting”find /roms -name '*.chd' -print0 |while IFS= read -r -d '' chd; do if ! openrom-core --input "$chd" --verify-only --json | jq -e '.success == true' >/dev/null; then echo "FAILED: $chd" fidoneWatch a download folder
Section titled “Watch a download folder”openrom-core \ --watch /downloads/roms \ --output /roms/incoming \ --format CHD \ --settle-seconds 15 \ --delete-sourceRun it under a process supervisor so it restarts after a reboot. A minimal systemd user unit:
[Unit]Description=OpenROM watch folder
[Service]ExecStart=/usr/local/bin/openrom-core --watch %h/downloads/roms --output %h/roms --format CHD --settle-seconds 15Restart=on-failure
[Install]WantedBy=default.targetsystemctl --user enable --now openrom-watch.serviceUse it from CI
Section titled “Use it from CI”A docs or patch repository can assert that every patch still applies:
- name: Check ROM tooling run: | openrom-core --version openrom-core --list-formatsPlugin repositories can validate and pack on every tag:
openrom-core --plugin-validate ./my-pluginopenrom-core --plugin-pack ./my-plugin --out "my-plugin-${TAG}.orplug"The packer computes SHA-256 hashes for each platform binary, so the archive is ready to upload to the Marketplace.
Parse JSON safely
Section titled “Parse JSON safely”--json writes one object per line, which is friendly to jq and to
line-oriented tools. Avoid parsing the human-readable output: the labels and
emoji are presentation, not an API.
openrom-core --json --audit-mame --dat mame.xml --folder /roms --only-present | jq -r 'select(.type == "done") | .machines[] | select(.status != "complete") | "\(.status)\t\(.name)"'Exit codes
Section titled “Exit codes”| Code | Meaning | Typical handling |
|---|---|---|
0 |
Success | Continue |
1 |
The operation failed (tool error, I/O, bad file) | Log and skip the file |
2 |
Invalid arguments or missing input | Fix the script |
With set -e, a single bad file aborts a batch. If you want to keep going,
|| true per file and collect failures yourself.
Portability notes
Section titled “Portability notes”- Quote every path. ROM collections contain spaces, brackets and parentheses.
- Pass
--outputexplicitly in scripts; never rely on writing beside the source. - Set
OPENROM_7Zwhen 7-Zip is installed outsidePATH. - In containers, mount both the ROM folder and the destination and run as a user that can write to the destination only.