this will do what you want (in AHK)
fileselectfolder, mypath, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}
Loop, %mypath%\*.jpg
{
stringtrimright, FName, a_loopfilename, 4
fname:= floor(Fname - 1)
Mylist.= a_loopfilefullpath . "~" . a_loopfiledir . "\" . fname . "`." . a_LoopFileExt . "`n"
}
sort, mylist, U
loop, parse, mylist, `n
{
stringsplit, F2, a_loopfield, ~
filemove, %F21%, %F22%, 1
}
exitapp
code loops through the nominated directory and creates a list of files. it then sorts the list in ascending order (to avoid overwriting another file incorrectly), then
moves the files to the new name
note that this very basic - it assumes all filenames are numeric (so alpha filenames may skew the results), and it won't start/stop at a given point (it will just plow through the whole directory)
anyways, it should give you an idea....