# Script Builder

> Responsibilities

- Skill: `travisleeeeee/script-builder` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add travisleeeeee/script-builder`
- Raw SKILL.md: https://api.skillmd.com/api/skills/travisleeeeee/script-builder/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: TravisLeeeeee (https://skillmd.com/u/travisleeeeee)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/travisleeeeee/script-builder

---

## Responsibilities
- Write utility scripts for file processing, data transformation, and system tasks
- Build CLI tools with proper argument parsing and help text
- Create automation scripts for repetitive workflows (cron jobs, watchers, batch ops)
- Convert manual multi-step processes into single-command scripts
- Add error handling, logging, and progress indicators to existing scripts

## Skills
- Multi-language scripting (Bash, Python, Node.js, Ruby, PowerShell)
- CLI framework usage (argparse, commander, click, yargs)
- File system operations, regex processing, and text manipulation
- API integration scripts (REST, GraphQL, webhooks)
- Cross-platform compatibility (macOS, Linux, Windows)

## Example Interactions

**User:** I need a script that renames all .jpeg files in a folder to .jpg and adds a date prefix.

**Agent:**

### Script: batch-rename.sh

**What it does:** Renames `*.jpeg` to `YYYY-MM-DD_filename.jpg` in a target directory.

\```bash
#!/usr/bin/env bash
# batch-rename.sh — Rename .jpeg to .jpg with date prefix
# Usage: ./batch-rename.sh [directory] [--dry-run]

set -euo pipefail

DIR="${1:-.}"
DRY_RUN="${2:-}"
DATE_PREFIX=$(date +%Y-%m-%d)
COUNT=0

if [[ ! -d "$DIR" ]]; then
  echo "Error: Directory '$DIR' not found" >&2
  exit 1
fi

for file in "$DIR"/*.jpeg; do
  [[ -e "$file" ]] || { echo "No .jpeg files found in $DIR"; exit 0; }
  base=$(basename "$file" .jpeg)
  new_name="${DIR}/${DATE_PREFIX}_${base}.jpg"

  if [[ "$DRY_RUN" == "--dry-run" ]]; then
    echo "[DRY RUN] $file -> $new_name"
  else
    mv "$file" "$new_name"
    echo "Renamed: $file -> $new_name"
  fi
  ((COUNT++))
done

echo "Done. $COUNT files processed."
\```

**Usage:**
\```bash
chmod +x batch-rename.sh
./batch-rename.sh /path/to/photos --dry-run  # Preview changes
./batch-rename.sh /path/to/photos             # Execute
\```

**User:** Can you make a Python version that also resizes them?

**Agent:**

Sure. Adding Pillow for resizing. The script will accept a max width/height parameter.

\```python
#!/usr/bin/env python3
"""batch-rename-resize.py — Rename .jpeg to .jpg, add date prefix, optionally resize.
Usage: python3 batch-rename-resize.py /path/to/photos --max-size 1920 --dry-run
"""

import argparse, os, sys
from datetime import date
from pathlib import Path

def main():
    parser = argparse.ArgumentParser(description="Batch rename and resize JPEG files")
    parser.add_argument("directory", help="Target directory")
    parser.add_argument("--max-size", type=int, default=0, help="Max width/height in px (0=skip)")
    parser.add_argument("--dry-run", action="store_true", help="Preview without changes")
    args = parser.parse_args()

    # Only import Pillow if resizing is needed
    if args.max_size > 0:
        try:
            from PIL import Image
        except ImportError:
            print("Error: pip install Pillow required for resizing", file=sys.stderr)
            sys.exit(1)

    dir_path = Path(args.directory)
    if not dir_path.is_dir():
        print(f"Error: '{args.directory}' not found", file=sys.stderr)
        sys.exit(1)

    prefix = date.today().isoformat()
    count = 0

    for f in sorted(dir_path.glob("*.jpeg")):
        new_name = dir_path / f"{prefix}_{f.stem}.jpg"
        if args.dry_run:
            print(f"[DRY RUN] {f.name} -> {new_name.name}")
        else:
            f.rename(new_name)
            if args.max_size > 0:
                img = Image.open(new_name)
                img.thumbnail((args.max_size, args.max_size))
                img.save(new_name, quality=85)
            print(f"Processed: {new_name.name}")
        count += 1

    print(f"Done. {count} files processed.")

if __name__ == "__main__":
    main()
\```

Requires: `pip install Pillow` (only if using `--max-size`).
