Batch Processing Local Files
Start with the safety line
Section titled “Start with the safety line”Batch operations mean one mistake affects hundreds of files. The only acceptable flow:
Scan (read-only) → report → you approve → batch → verifyNever skip the scan or the approval.
Step 1: read-only scan
Section titled “Step 1: read-only scan”Have it investigate without changing anything.
Scan ~/Downloads and report:
- Total file count and disk usage
- Breakdown by type (images/docs/video/other)
- Files over 100MB
- Likely duplicates (same name or identical size)
- How many files are older than one year
Report only. Do not move, rename, or delete anything.
That last sentence is mandatory. Without it, it will probably “helpfully” start tidying.
Step 2: review the report yourself
Section titled “Step 2: review the report yourself”- Are the categories right?
- Anything in there that shouldn’t be touched?
- Do the numbers match expectations? (Expected 500, got 5,000 → wrong path)
This is your cheapest intervention point. A one-line correction now beats a rollback later.
Step 3: execute in batches
Section titled “Step 3: execute in batches”Ten files maximum per batch. Verify, then continue.
Process the first 10 files per the plan. Report what you did; wait for my go-ahead before continuing.
Batching caps the damage if the strategy turns out to be wrong.
Step 4: trash, never delete
Section titled “Step 4: trash, never delete”❌ rm -rf # unrecoverable✅ move to Trash / gio trash / trash-putDeletions must go through the trash. If none is available, don’t delete — move to a backup directory and clean it up manually later.
Back up before starting
Section titled “Back up before starting”cp -r ~/Downloads ~/Downloads_backup_$(date +%Y%m%d)Confirm the backup succeeded, then begin. Disk space for peace of mind is always a good trade.
Three real scenarios
Section titled “Three real scenarios”Sorting a downloads folder
Sort ~/Downloads into subfolders by type: images → Images, docs → Documents, archives → Archives, installers → Installers. Only handle files modified in the last 30 days; leave anything older alone. Ten per batch, report after each.
Batch renaming
Rename everything in ~/Photos/trip to YYYY-MM-DD_sequence.jpg based on capture date. Show me the rename table first. Wait for approval before executing.
Format conversion
Convert all .doc files in ./docs to .docx, verify each converted file opens, list any failures, and don’t delete the originals.
Red flags — stop and think
Section titled “Red flags — stop and think”- Recursive operations targeting Desktop, Downloads, Documents, or Home
rm -rf,del /S /Q, wildcard deletes- Vague requests with huge blast radius (“clean up useless files”)
- Anything touching system directories (
/System,AppData,Library)
Vague request → clarify first, then still only scan. “Clean up my computer” needs the target directory, file types, and criteria before a single file moves.