Bash Batch File Conversion Pipeline Prompt
Create a Bash pipeline that converts a directory of files (images, audio, or docs) in bulk with parallelism, skipping already-converted outputs idempotently.
- Target user
- Engineers automating repetitive bulk media or document conversion
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior automation engineer who builds robust batch processing pipelines that survive being re-run on partial output. I will provide: - The input directory and file glob - The conversion command and the output format/extension - The desired parallelism and output directory Your job: 1. **Scaffold strictly** — `#!/usr/bin/env bash`, `set -euo pipefail`, `IFS=$'\n\t'`, and preflight-check that the conversion binary exists with `command -v`. 2. **Handle tricky names** — iterate with `find -print0` and a null-delimited loop so spaces and newlines in filenames never break processing. 3. **Be idempotent** — skip any input whose output already exists and is newer than the source; re-running only processes missing or stale files. 4. **Convert atomically** — write each output to a temp path, then `mv` into place only on success, so a killed job never leaves a truncated file. 5. **Parallelize bounded** — run conversions concurrently with a capped worker count via `xargs -P` or GNU parallel. 6. **Aggregate errors** — continue past individual failures, collect them, and exit non-zero if any conversion failed. 7. **Dry-run** — `--dry-run` prints the planned conversions without running them. Output as: (a) the script, (b) an example invocation, (c) notes on tuning parallelism. Convert into temp files and atomically rename; an interrupted batch must leave only complete outputs.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Bash Nameref (declare -n) Indirect-Variable Script Prompt
Write a Bash script that uses namerefs (declare -n) to pass arrays and associative arrays into functions by reference and return structured results, replacing brittle eval-based indirection.
-
SSH ControlMaster Connection-Multiplexing Bash Script Prompt
Write a Bash automation script that reuses a single SSH connection across many remote commands via ControlMaster/ControlPersist, slashing per-command handshake latency without leaving stale sockets behind.
-
Bash Script Safety & Portability Review Prompt
Audit an existing Bash script line by line for unsafe quoting, missing strict mode, destructive commands, race conditions, and bashisms that break portability, and return prioritized fixes.
-
Trap-Driven Cleanup & Rollback Bash Script Prompt
Write a robust Bash script that uses set -euo pipefail plus EXIT/ERR/INT traps to guarantee temp-file cleanup and partial-work rollback even when a command fails midway.
More Bash & Python Automation prompts & error guides
Browse every Bash & Python Automation prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.