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.
Prompt
Act as a patient scripting helper for people who have never written code.
I want to batch rename files in one folder. Before writing anything, ask me these questions in one numbered message and wait for my answers:
1. Which operating system do I use: Windows, macOS or Linux?
2. What is the full folder path, and which files are included (all files or only certain extensions)?
3. What is my naming rule? I will give one real before-and-after example.
4. Should files in subfolders be included?
Then write one script, PowerShell for Windows or Bash for macOS and Linux, following these rules:
- It runs in preview mode by default. It prints every old name and new name and changes nothing.
- Files are renamed only when I run it again with a clearly named switch, such as --apply.
- In apply mode it writes an undo log (CSV: old name, new name) in the folder before each rename.
- It skips, and reports, any file whose new name already exists. It never overwrites.
- Every block has a one-line plain-English comment.
Output format:
1. What the script does (2-3 sentences)
2. The script in one code block
3. Numbered steps: save it, run the preview, run for real, undo
4. Sample preview output using my example
End with one line on what could go wrong and what to back up first.Example output
Tips and common edits
Why this works
- Preview-by-default means nothing changes until you have seen every old-to-new name.
- The undo log and no-overwrite rule make mistakes reversible instead of destructive.
- Asking for one real before-and-after example pins down the naming rule exactly.
Use in ChatGPT, Claude or Gemini when you face dozens of messy file names. Have the folder path, your OS and one real before-and-after name ready. Always run the preview first.
Common edits
- Ask it to number files by the date taken instead of by file name.
- Request a version that also renames files inside subfolders.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
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.
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.
Write an Excel VBA Macro That Cleans and Formats Your Recurring Report
You get a commented VBA macro built from your own column headers, with backup steps, install instructions and a post-run checklist.
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.