Write a Safe Automation Script with Dry Run and Error Handling
Get a commented shell or Python script for your repetitive task, with a dry-run flag, clear error handling and a test command to try on sample files first.
You getPlan, script and how to run
Prompt
Act as a senior automation engineer who writes small, safe scripts for people who are not full-time programmers.
Your job: write a shell or Python script that automates a repetitive task for me. Before writing any code, ask me these questions in one numbered message, then wait for my answers:
1. Which operating system and shell do I use, and is Python 3 installed?
2. What is the task, step by step, the way I do it by hand now?
3. What are the inputs (folders, file types, example names) and what should the output look like?
4. What must never happen (overwriting, deleting, touching certain folders)?
Rules:
- Include a --dry-run flag that prints every planned action without changing anything.
- Handle missing paths, permission errors and name collisions with a clear message; never overwrite or delete silently.
- Use only the standard library or built-in tools unless I agree to install something.
- Add a one-line plain-English comment above each block.
- Give a test command that creates 3-5 sample files in a temporary folder and runs the script on them.
Output format:
1. Plan (3-5 bullets)
2. Script (one code block)
3. How to run (dry run first, then real run)
4. Test command
5. Checks before using it on real files
End with one line listing your assumptions and any risk of data loss.Example output
Tips and common edits
Why this works
- Asking for OS, inputs and forbidden actions first stops the model from guessing paths, shells or file patterns.
- A required --dry-run flag and no-overwrite rule make the first run harmless, even for beginners.
- The disposable test command proves the script works on fake files before it touches real data.
Use when you keep renaming, moving or converting files by hand. Have your OS, a few example file names and the result you want ready. Works in ChatGPT, Claude or Gemini.
Common edits
- Ask for a PowerShell version if you are on Windows and cannot install Python.
- Ask it to add a log file or a cron/Task Scheduler line so the script runs automatically.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
Batch Rename Files in a Folder with a Script You Can Preview First
You get a PowerShell or Bash rename script that shows every old-to-new name before changing anything, writes an undo log, and includes plain run steps.
Build an Excel Formula from a Plain-English Description of What You Need
You get a working Excel formula, versions for older Excel and Google Sheets, a one-row worked example, and a table of the blank and error cases it handles.
Check If You Can Scrape a Website and Plan a Polite Scraper First
You get a Go or Don't verdict based on robots.txt, terms and privacy risks, a list of API or export alternatives, and a step-by-step polite scraping plan.
Combine and Clean Multiple CSV or Excel Files into One Table with Power Query
You get a header mapping table, numbered Power Query clicks, commented M code that fixes mismatched columns and duplicates, and refresh steps for new files.
Turn Your Inbox Problems into Gmail or Outlook Rules You Can Set Up Today
Get a numbered set of Gmail filters or Outlook rules with exact conditions, actions, run order, conflict warnings, setup clicks and a test for each rule.
Write a Google Apps Script to Automate a Repetitive Google Sheets Task
You get a commented Google Apps Script built around your sheet names, columns and timing, plus install steps, a test plan on a copy, and undo steps.