Simple auto-enumerate-rename files script

Post your working scripts, libraries and tools for AHK v1.1 and older
a0l0e0x000
Posts: 14
Joined: 26 Dec 2020, 08:27

Simple auto-enumerate-rename files script

Post by a0l0e0x000 » 26 Dec 2020, 08:47

My first script, with very simple commands. Open to suggestions :)

Hotkey: The script is assigned to Ctrl+shift+alt+F12, but can easily be remapped by editing the code. (You need to edit the code in all 3 places!)
How To Use: It will rename files in order, adding "n " at the beginning of the file name (where n is the number (1,2,3...)). You simply click on the starting file and hold down the hotkey. As long as it is held down the file, and later files underneath it, will have numbers added at the beginning of their name. It won't happen instantly so when you get to the last file you have to let go of your hotkey.
Applications: Ever had your files ordered by date in Explorer and you want them to stay in order (sometimes when sending files the date metadata will get lost or overwritten mixing up everything)? Simply enumerate the names with this script to fix them in order for good. :)

Code: Select all

^+!F12::
n := 1
while GetKeyState("F12","P")
Loop 50
{
	{
		if not (GetKeyState("F12","P"))
			{
			break
			}
		Send, keys {F2}{Left}%n% {Enter}{Down}
		n := n+1
		Sleep,0
	}
}
return
If you want it to rename files slower Change the "0" after "Sleep," into a different number (1000 = 1s)
I recommend making a set of test files at first and try renaming them to get the hang of it, but it is very intuitive.
If you want to edit the way it formats numbers edit the section between "{Left}" and "{Enter}".

Return to “Scripts and Functions (v1)”