Batch Process Files with AI
Process multiple files at once with AI. Rename, convert, analyze, and transform batches of files using Bash and Glob tools.
You have 100 files that need the same operation: rename, convert, analyze, or transform. Doing them one at a time is tedious. AI with file tools handles the batch.
The Quick Recipe
“Find all .png files in ~/Screenshots/ and rename them with today’s date prefix (2026-02-11-originalname.png)”
Chapeta uses Glob to find files, generates the rename commands, and executes them with the Bash tool.
File Renaming
Date Prefix
“Find all files in ~/Downloads/ and rename them with their modification date as a prefix (YYYY-MM-DD-filename)“
Format Standardization
“Find all files in ~/Photos/ with spaces in the filename. Replace spaces with hyphens and make everything lowercase.”
Sequential Numbering
“Find all .jpg files in ~/project/assets/ and rename them sequentially: image-001.jpg, image-002.jpg, etc.”
Extension Fixing
“Find all .jpeg files in ~/Photos/ and rename the extension to .jpg”
File Organization
Sort by Type
“Find all files on my Desktop and move them into folders by extension: PDFs to ~/Desktop/PDFs, images to ~/Desktop/Images, docs to ~/Desktop/Documents”
Sort by Date
“Find all files in ~/Downloads/ and organize them into folders by month (2026-01, 2026-02, etc.)”
Sort by Content
“Find all .txt files in ~/Documents/. Read the first line of each and move files about ‘Project Alpha’ to ~/Documents/ProjectAlpha/”
This combines Glob (find), File Read (check content), and Bash (move) for content-based sorting.
Batch Analysis
File Inventory
“List all files in ~/projects/myapp/ grouped by extension. Show the count and total size for each type.”
Find Duplicates
“Find all files in ~/Documents/ that have the same name but different paths. List the duplicates.”
Size Report
“Find the 20 largest files in my home directory. List each with its size and path.”
Code Metrics
“Find all .ts files in ~/projects/myapp/src/. For each, count the lines of code. Show the top 10 largest files.”
Batch Conversion
Markdown to Text
“Find all .md files in ~/notes/. For each file, strip the markdown formatting and save as .txt in ~/notes/plain/“
JSON Formatting
“Find all .json files in ~/data/. Read each one and rewrite it with proper indentation (pretty-print).”
Character Encoding
“Find all .csv files in ~/data/. Check the encoding and convert any non-UTF-8 files to UTF-8.”
Batch Content Processing
Add Headers to Files
“Find all .md files in ~/blog-drafts/. For each file that doesn’t start with ’---’ (frontmatter), add a YAML frontmatter block with the filename as the title.”
Search and Replace Across Files
“Find all .html files in ~/website/. Replace ‘http://’ with ‘https://’ in all of them.”
Extract Data from Multiple Files
“Find all .log files in ~/logs/. From each file, extract lines containing ‘ERROR’ and save all errors to ~/logs/all-errors.txt”
Safety Tips
Batch operations on files are powerful but potentially destructive. Best practices:
- Always review the commands Chapeta wants to run before approving
- Start small: Test with one file before running on the full batch (“move the first file as a test”)
- Use copies: “Copy files to a new directory” is safer than “move files” when testing
- Check the count: “How many files match this pattern?” before running the operation
- Avoid rm in batches: Deleting files in bulk is risky. Move to trash instead when possible
Limitations
Chapeta processes files sequentially through its tools, not in parallel. Very large batches (thousands of files) may take time. The Bash tool runs commands one at a time with confirmation, so bulk operations require multiple approvals unless Chapeta scripts them into a single batch command. File operations are limited to what the terminal can do; specialized operations like image resizing or video conversion need dedicated tools (though Chapeta can invoke them through Bash if they are installed).