Jump to content

search multiple ini's and extract data into table

Recommended Posts


Hi everyone,

Let me first start off by saying I love the many things people have posted and created. I have found many useful things to apply this to at my current job. I usually can find examples and tailor them to my specific needs, but this time I am a little stumped. My coding isn't the greatest and like I said, I can usually find what I need in the help or forums. But this time I am stumped. 

Scenario: I have been tasked to search and extract specific data from our ini files. My problem I run into is doing a global search across all of ini's and extracting the defined data.

The key value I am searching on within each ini file is "HTTPServer". Can someone help me in performing the mass search/extract part.

So far my script will extract the information I need, but it requires me to specify the ini name within the .au3 file. Like I said before, I would like to search the directory for all ini's named "drsys*.ini" and spit out all results

I will attach 2 test.ini files that have been stripped down for simplicity sake that the code will look at. Any help would be greatly appreciated.

#include <Array.au3>
#include <MsgBoxConstants.au3>

;~ Location of specific ini.
;~ **********NOTE: This is a temp location, need it to search for drsys*.ini and extract from all ini within directory defined
$sFile = @DesktopDir & "\drsys0001.ini"

;~ Search the ini for section name containing "HTTPServer"
$sSearch = "HttpServer"

; Get section name from ini
$aSections = IniReadSectionNames($sFile)

; Clear the result variable
$sResult = ""

; Loop through the section names gathering the results
For $i = 1 To $aSections[0]
    ; if we find the search variable in the section name
    If StringInStr($aSections[$i], $sSearch) Then
        ; We get the key/value pairing
        $aKey = IniReadSection($sFile, $aSections[$i])
        ; And add them to the result
        $sResult &= $aKey[1][0] & "=" & $aKey[1][1] & @CRLF

; Results from ini
MsgBox(0, "Result for " & $sSearch, $sResult)









Share this post

Link to post
Share on other sites

If I understand correctly...

You could set up your search loop as a Function and call that function from a script using:


Loop through the array looking for: "drsys*.ini"

and send those files to your function for parsing...

Share this post

Link to post
Share on other sites

Or specify "drsys*.ini" as filter in _FileListToArray. So you get an already filtered array which means you need to call your function for every row in the array.

My UDFs and Tutorials:


Active Directory (NEW 2018-12-03 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version - Download - General Help & Support - Example Scripts - Wiki
iCal (2019-01-22 - Version - Download - General Help & Support
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now