Skip to content

surrealier/Windows_Renamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏷️ win_rename

Batch-add a prefix/suffix to your files — right inside Windows Explorer.

Select files → hit Alt+F2 → type → done. No cloud. No telemetry. No 200 MB installer. Just one tiny tray app. 🪶

Download win_rename.exe

Platform AutoHotkey v2 License: MIT Tests PRs welcome

win_rename demo

😩 The problem

You pick 10 files in Explorer, press F2 to rename them all at once... and Windows names them all the same with a counter:

사진 (1).jpg   사진 (2).jpg   사진 (3).jpg   😭

But you didn't want that. You just wanted to slap 2024_ on the front. That's it.

✨ The fix

win_rename keeps every original filename and just adds your prefix and/or suffix — with a live preview before anything touches the disk.

report.pdf   →   2024_report_final.pdf      (prefix "2024_",  suffix "_final")
data.xlsx    →   2024_data_final.xlsx
photo.jpg    →   2024_photo_final.jpg

The suffix goes before the extension, so .pdf / .jpg stay intact. 👌


🚀 Quick Start

TL;DR — download the exe, double-click, press Alt+F2 in Explorer.

⚡ Option A — Download & run · Recommended

1. ⬇️ Just Install! win_rename.exe

2. Just Execute!

3. In Explorer, select filesAlt+F2

4. Type a prefix / suffixApply

No AutoHotkey. No setup. Nothing to clone.

🧩 Option B — Run the script

Prefer the raw .ahk? You just need AutoHotkey v2 — a normal program installed once, system-wide (not per-folder, not inside the repo):

1. winget install AutoHotkey.AutoHotkey (run anywhere, one time)

2. Double-click win_rename.ahk

3. Same as above → select files → Alt+F2 → type → Apply

win_rename dialog

🧠 Features

  • 🏷️ Prefix + suffix in one shot — suffix lands before the extension
  • ✂️ Remove text — strip a leading or trailing string before adding (re-prefix in one pass). Tick * wildcard” and _v* auto-removes versioned suffixes like _v1, _v2, _v3
  • 🔢 Auto-increment counter — append 00001, 00002, … before the extension; set the zero-padding & start number with the ▲▼ spinners
  • 👀 Live preview — see old → new for every file as you type
  • 🛡️ Safe by default — blocks illegal characters, never overwrites existing files, isolates per-file failures
  • 🪟 Windows 11 tab-aware — reads the selection from the active Explorer tab, not a random one
  • 🗂️ Files and folders
  • ⌨️ Context-smart hotkeyAlt+F2 only fires in Explorer/Desktop; everywhere else the key behaves normally
  • 🪶 Featherweight — a single tray app, no background bloat

built-in F2 vs Renamer Alt+F2

built-in F2 Renamer Alt+F2
Keep original names ❌ all become the same
Add prefix
Add suffix (before extension)
Live preview
Folders too ⚠️

⚙️ How it works (for the curious)
Step Mechanism
Hotkey scope GroupAdd (CabinetWClass / WorkerW / Progman) + #HotIf WinActive("ahk_group …") — stays on the optimizer fast path
Read selection enumerate Shell.Application.Windows → match the active window's HWND → on Win11, resolve the active tab via ShellTabWindowClass1 + IShellBrowser::GetWindowDocument.SelectedItems().Path
Name transform SplitPathprefix + nameNoExt + suffix + "." + ext
Rename file FileMove(…, 0) / folder DirMove(…, "R"), each wrapped in try/catch

Case-only renames (a.txt → A.txt) and cyclic swaps are handled via temporary names.

📦 Build the .exe yourself (optional — a prebuilt one is in Releases)
& "<path-to>\Ahk2Exe.exe" `
  /in  "win_rename.ahk" `
  /out "win_rename.exe" `
  /base "C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe"

/base must point at a v2 base file.

⚠️ Notes & gotchas
  • Don't run as admin. If the app is elevated while Explorer isn't (the normal case), Windows hides the selection from it and you'll get an empty list. Renames in protected folders (Program Files, Windows, …) show up as per-file "Access Denied".
  • Dotfiles (.gitignore) are treated as extension-only, so affixes are prepended: 2024__final.gitignore. The preview shows exactly what will happen.
  • Laptop F-row in media mode? Use Fn+Alt+F2, or flip the firmware (BIOS) function-key setting.
  • SmartScreen may warn on the unsigned .exe the first time → More info → Run anyway (or use Option B).
🧪 Tests

test_win_rename.ahk ships 59 automated tests (name transform, validation, counter, remove, * wildcard, on-disk rename engine, collisions, partial-failure isolation), and test_apply.ahk is a GUI integration test that clicks Apply and verifies an on-disk rename:

& "$env:LOCALAPPDATA\Programs\AutoHotkey\v2\AutoHotkey64.exe" test_win_rename.ahk
# report → %TEMP%\win_rename_test_result.txt

▶️ Start with Windows

The .exe auto-registers on its first run, so it starts with Windows out of the box. Toggle it any time from the tray icon → Add / Remove from Startup (your choice is remembered).

🗑️ Uninstall

It's portable, so cleanup is tiny. Run uninstall.bat (bundled in the release) — it stops the app, removes the startup shortcut + registry marker, and optionally deletes win_rename.exe. Prefer manual? Tray → Remove from StartupExit, then delete the file.


🤝 Contributing

Issues and PRs welcome! Ideas: find & replace, case conversion, regex mode, drag-to-reorder.

⭐ Like it?

If win_rename saved you from a rename rage-quit, drop a star — it genuinely helps. 🙌

📄 License

MIT — do whatever, just keep the notice.

About

Add a prefix/suffix to many files at once in Windows Explorer — select files, press Alt+F2, done. Lightweight AutoHotkey v2 tray tool.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors