Skip to content

LORDLYAMIGO/Smart-Powershell-Renamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Smart Powershell Filerenamer (PowerShell)

A simple interactive PowerShell script that uses a generative LLM (by default Google Gemini via the Generative Language API) to suggest descriptive, filesystem-safe filenames for all files in a folder — then previews and optionally applies the renames.

Features

  • Collects filenames in a folder and sends them to an LLM with your custom instruction (e.g., "Make filenames descriptive and professional").
  • Requests a JSON array of new filenames (without extensions) to ensure predictable parsing.
  • Previews the proposed renames and asks for confirmation before applying changes.
  • Sanitizes suggested names to remove invalid filesystem characters and prevents overwriting existing files.

Requirements

  • Windows PowerShell (the script uses standard PowerShell cmdlets)
  • curl available in the system PATH
  • A valid Google Generative Language API key (set in the script)
    • Can be modified to LLM of your choice.

Usage

  1. Set your API key in the script: $ApiKey = "YOUR_REAL_API_KEY"
  2. Run the script in PowerShell.
  3. When prompted:
    • Enter the folder path containing files to rename.
    • Enter a rename prompt (e.g., "Make filenames descriptive and professional").
  4. Review the LLM-proposed filenames shown in order.
  5. Confirm (Y) to apply the renames or cancel.
Screenshot 2025-10-31 132335 File Names Before Script Usage Script Output Script Output 2 File Names After

How it works (brief)

  • The script enumerates files in the provided folder.
  • It builds a prompt containing the user's instruction and the current filenames, asking the LLM to return a JSON array of new base filenames (same order, no extensions).
  • The response is parsed, validated (count and JSON), previewed, sanitized, and then applied after user confirmation.

Response format requirement

The script instructs the LLM to respond ONLY with a valid JSON array of strings (no file extensions), e.g.: ["Invoice_2025-09", "ProjectPlan_Backup", "Photo_Vacation_01"]

This strict format reduces parsing errors and accidental output noise.

Safety notes

  • The script will not overwrite existing files; suggested renames that collide with existing filenames are skipped.
  • It sanitizes filenames to remove characters invalid on Windows/Unix (, /, :, *, ?, ", <, >, |).
  • Always review the preview before confirming.

Troubleshooting

  • If curl is not found, install curl or run on a system with curl available.
  • If the LLM response cannot be parsed as JSON, inspect the raw output printed by the script (it removes common Markdown fences before parsing).
  • Ensure your API key is set and valid for the endpoint used.

License

MIT License

About

A simple interactive PowerShell script that uses a generative LLM (by default Gemini 2.5 Flash) to suggest descriptive, filesystem-safe filenames for all files in a folder then previews and optionally applies the renames.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors