简体   繁体   中英

Running a file inside a folder that contains string in autohotkey

I need to run a file inside a folder that always changes a version. I tried Run "E:\Test. \TestScript.exe" While Test. is physically Testv1.22 But obviously I need a regex command to run it and i have no idea how to do that. Any help would be appreciated.

I first looped through all of the exes in the directory provided ( E:\Test\ ).

Next, I used RegExMatch on the current file name of the current iteration of the loop as the haystack, and Testv.*Script.exe as the needle.

This needle will allow for file names of the format "Testv"+[any combination of characters]+"Script.exe" to be accepted as matches.

If it gets a match, then I run the full path of the current file, launching the exe.


Final code:

Loop, Files, E:\Test\*.exe
{
    ;MsgBox %A_LoopFileName% ;uncomment to see the file currently being iterated
    if(RegExMatch(A_LoopFileName, "Testv.*Script.exe")){
        run %A_LoopFilePath%
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM