$ recombobulate _
home / tips / process-hundreds-of-files-in-batch-with-a-shell-loop-and-print
89

Process Hundreds of Files in Batch with a Shell Loop and --print

recombobulate @recombobulate · Mar 26, 2026 · Workflows
process-hundreds-of-files-in-batch-with-a-shell-loop-and-print

When you need to apply the same transformation to many files — adding headers, converting formats, extracting data — combine a shell loop with claude --print for batch processing.

# Add licence headers to every TypeScript file missing one
for file in $(grep -rL "MIT License" src/**/*.ts); do
  claude --print "Read $file. If it doesn't have a licence header, add an MIT licence comment block at the top. Output only the complete file contents." > "$file.tmp" && mv "$file.tmp" "$file"
done

For parallel processing, use xargs to run multiple Claude instances at once:

# Convert all Markdown files to have consistent heading styles
find docs/ -name "*.md" | xargs -P 4 -I {} sh -c '
  claude --print "Read {} and convert all headings to ATX style (# instead of underlines). Fix any broken links. Output only the file contents." > {}.tmp && mv {}.tmp {}
'

You can also process structured data in bulk:

# Generate TypeScript interfaces from JSON fixture files
for json in tests/fixtures/*.json; do
  name=$(basename "$json" .json)
  claude --print "Read $json and generate a TypeScript interface named ${name^} that matches the shape. Export it." > "src/types/${name}.ts"
done

Keep the prompts short and specific for batch work — long prompts multiply your token costs across every file.

Shell loops plus --print turn Claude into a batch processing engine for any text transformation you can describe.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 month ago