Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cemerson/156e7879545fbfbcd530bbe314370503 to your computer and use it in GitHub Desktop.
Save cemerson/156e7879545fbfbcd530bbe314370503 to your computer and use it in GitHub Desktop.
Autohotkey (v1): Rename images while viewing in Windows Preview app!
;(SHIFT+F2) RENAME IMAGES WHILE IN WINDOWS PREVIEW! CE v20250512064016
+F2::
Send, ^{Tab} ; Switch to File Explorer
Sleep, 200
Send, ^c ; Copy selected file path
Sleep, 200
ClipWait, 1
file := Clipboard
if !FileExist(file) {
MsgBox, Could not get file path from Explorer.
return
}
SplitPath, file, name, dir, ext, nameNoExt
; Get last modified date and format as yyyyddmm
FileGetTime, modTime, %file%, M
FormatTime, formattedDate, %modTime%, yyyyMMdd
; Build default input string: nameNoExt-yyyyddmm
defaultName := nameNoExt "-" SubStr(formattedDate, 1, 4) SubStr(formattedDate, 7, 2) SubStr(formattedDate, 5, 2)
; Display input box with pre-filled text
InputBox, newname, Rename File, Enter new name for the file:, , 300, 130, , , , , %defaultName%
if (newname != "" && newname != nameNoExt)
{
newfullpath := dir "\" newname "." ext
FileMove, %file%, %newfullpath%
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment