donhorn20 Posted June 17, 2016 Share Posted June 17, 2016 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 EndIf Next ; Results from ini MsgBox(0, "Result for " & $sSearch, $sResult) drsys0001.INI drsys0002.INI Link to comment Share on other sites More sharing options...
l3ill Posted June 17, 2016 Share Posted June 17, 2016 If I understand correctly... You could set up your search loop as a Function and call that function from a script using: _FileListToArray Loop through the array looking for: "drsys*.ini" and send those files to your function for parsing... My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
water Posted June 17, 2016 Share Posted June 17, 2016 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: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now