Code: Select all
#IfWinActive ahk_exe explorer.exe
SetBatchLines, -1
;-------------------------------hotkeys
F1::
;-------------------------------hotkeys
;--------------------------------labels
Renombrar_numerar:
if WinExist("ahk_class CabinetWClass"){
ControlGetText currentPath, ToolbarWindow323, ahk_class CabinetWClass
if (currentPath){
; pathActiveExplorer := SubStr(currentPath, 10) ;windows en Ingles
pathActiveExplorer := SubStr(currentPath, 12) ;windows en español
FindLast_rename_n(pathActiveExplorer)
}
}
Return
;--------------------------------labels
;--------------------------------Function
FindLast_rename_n(Ruta){
File := ""
TimeMod := ""
Loop, Files, %Ruta%\*.*,F
{
If (A_LoopFileTimeModified >= TimeMod)
{
TimeMod := A_LoopFileTimeModified ; the time the file was last modified
File := A_LoopFileFullPath ; the path and name of the file currently retrieved
}
totalFiles := A_Index
}
if (File){
SplitPath, Ruta, NameFolder
SplitPath, File, , , extFile,
nameForNewFile := Ruta "\" NameFolder " ("totalFiles ")." extFile
if (File != nameForNewFile){
FileMove, %File%, %nameForNewFile% ; Rename a single file.
}
}
Send, ^!1
}
;--------------------------------Function
#IfWinActive