So I have tried to create backup copies of the script in a safe folder every time it runs, wiuth this line at the beginning of the script.
FileCopy, % A_ScriptFullPath, % SubStr(A_ScriptFullPath, 1, -3) . "RUN-TIME COPY.AHK", 1 ; Backup copy in case of catastrophic error
I have been able to create ONE backup copy with no problem, but I have found that is not enough. I might have to revert the script to the version I was using hours ago, and thus one backup copy is not enough. I need five at least.
So I did something like this...
Code: Select all
num:=1
While num<5 {
If FileExist(A_ScriptDir . "\Backups Autohotkey organizado y funciones\" . SubStr(A_ScriptName, 1, -4) . "versión " . num . ".AHK")
num++
else
{
FileCopy, % A_ScriptFullPath, % A_ScriptDir . "\Backups Autohotkey organizado y funciones\" . SubStr(A_ScriptName, 1, -4) . "versión " . num . ".AHK", 1 ; Hago copia de seguridad en caso de error catastrófico
Break
}
}
So , in short, I need the script to check if there are 5 versions of my script. If there are less, create another one with a higher version number (until 5). If all five versions exist, restart making backup copies of the script starting with 1, next time with 2, etc.
I am not sure how the script can keep a check on what file was saved last (and making it time-efficient!) and then incrementing the version number by one, unless it's 5, when it should start back to 1.
Did I explain myself?
Thank you!