Hi everyone,
I am currently using an AHK script I created to write some simple reports to ini files.
I would like to be able to create a simple button in my GUI which can help me to search for / recall reports based on name.
Inside each INI file is a field called, "Name" under the section "General". The names contain spaces as they are in first, middle, last format. What I want to be able to do is have the user enter part of or the full name in an edit box and press search I would then like for the script to crawl a specific directory and all the .ini files inside and look at the "Name" field of each INI and attempt to match part or all of the name and thus show the resulting file name which matches.
What I am not sure how to do is the search, I assume I could create a loop which will crawl the folder (not positive on syntax) and then inside the loop have it open the INI files one by one and reach the name field with IniRead and attempt to compare the string from the edit box vs the iniread input. I have a general idea but not sure where to get started on the code.
Any help would be greatly appreciated!
Thank you
Searching files Topic is solved
Re: Searching files Topic is solved
You are on the right track. Here is some (untested) syntax to inspect:
Code: Select all
pattern := "bla"
filelist := ""
loop, *.ini {
iniread, name,% a_loopfilefullpath, General, Name
if (instr(name, pattern)){
filelist .= a_loopfilefullpath . "`n"
}
}
msgbox,% filelist
Re: Searching files
Firstly - thank you kindly.
The code snippet works well for what I need however it only searches for .ini files in the directory the script is run from. Is there a way to specify the directory it should search assuming it is not the same running directory as the script?
The code snippet works well for what I need however it only searches for .ini files in the directory the script is run from. Is there a way to specify the directory it should search assuming it is not the same running directory as the script?
Re: Searching files
Code: Select all
loop, path\to\*.ini
Who is online
Users browsing this forum: garry, marypoppins_1, mikeyww, OrangeCat, RussF and 152 guests