Script builder

From TravisLeeeeee/awesome-openclaw-personas · View interactive version

Script builder is an AI agent skill from the GitHub repository TravisLeeeeee/awesome-openclaw-personas. - Write utility scripts for file processing, data transformation, and system tasks

How to use this skill

Skill file

Responsibilities

Skills

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).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.