mscreffcs Posted August 28, 2008 Posted August 28, 2008 Hello guys, I need your help. I want to search for a string <find_me> in list of *.xml files in a folder and in return I want to create a report like, For example, Filename Error description text.xml TRUE ; if tag found blahblan.xml FALSE ; if tag not found. Hope you can reply to me as soon as possible. ) Kind Regards, Deepak
mscreffcs Posted August 28, 2008 Author Posted August 28, 2008 Here are some lines from the code I am working on: #include <file.au3> #Include <Array.au3> ;Search folder $root = "C:\autotest\test" ;Grab list of txt files $FileList = _FileListToArray($root,"*.txt") ;_ArrayDisplay($FileList,"$FileList") ;Loop through text files For $X = 1 to $FileList[0] ;Combine filename with source folder $FileName = $root & "\" & $FileList[$X] ;Read file contents $String = FileRead($FileName) ;Find name $array = StringRegExp($string,"<find_me>",1) ;If name found, display it ; If IsArray($array) Then ;Firstname Lastname MsgBox(0,"", $array) ;EndIf Exit Hope this will help to resolve my problem. ------------------------------------ AUTOIT EXPERTS ARE YOU LISTENING!!! -----------------------
enaiman Posted August 28, 2008 Posted August 28, 2008 You've done a big part yourself Because you were a "good boy", here is the code: #include <file.au3> #Include <Array.au3> ;Search folder $root = "C:\autotest\test" $report = FileOpen($root&"\report.txt", 2) ;open the report and erase previous content - or create file if it doesn't exist ;Grab list of txt files $FileList = _FileListToArray($root,"*.txt") ;_ArrayDisplay($FileList,"$FileList") ;Loop through text files For $X = 1 to $FileList[0] ;Combine filename with source folder $FileName = $root & "\" & $FileList[$X] ;Read file contents $String = FileRead($FileName) If StringInStr($String, "<find_me>") > 0 Then FileWriteLine($report, $FileList[$X]&" TRUE") Else FileWriteLine($report, $FileList[$X]&" FALSE") EndIf Next FileClose($report) Exit SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
mscreffcs Posted August 28, 2008 Author Posted August 28, 2008 You've done a big part yourself Because you were a "good boy", here is the code: #include <file.au3> #Include <Array.au3> ;Search folder $root = "C:\autotest\test" $report = FileOpen($root&"\report.txt", 2) ;open the report and erase previous content - or create file if it doesn't exist ;Grab list of txt files $FileList = _FileListToArray($root,"*.txt") ;_ArrayDisplay($FileList,"$FileList") ;Loop through text files For $X = 1 to $FileList[0] ;Combine filename with source folder $FileName = $root & "\" & $FileList[$X] ;Read file contents $String = FileRead($FileName) If StringInStr($String, "<find_me>") > 0 Then FileWriteLine($report, $FileList[$X]&" TRUE") Else FileWriteLine($report, $FileList[$X]&" FALSE") EndIf Next FileClose($report) Exit YOU ROCK! Thanks a lot!
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