gempie Posted July 4, 2006 Share Posted July 4, 2006 Hello, What i want to achief is the following. I want all .doc files in a specific dir (c:\pet) to be processed. All .doc files have to be read until it finds string "A total of" from here on i want all the info from "A total of" until the EOF. This info (from all .doc files) i want to put in a result file. this is what i have so far. Thx for looking in to this $iHandle = FileOpen ('result.doc',1) $file = FileOpen("_DailyQC_20060313.doc", 0) If $file = -1 Then Exit EndIf $save = "" ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If StringInStr($line, "A total of ") Then $save = $line WEnd FileClose($file) FileWrite($iHandle,_ $save) FileClose($iHandle) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 4, 2006 Moderators Share Posted July 4, 2006 Local $MainFile = @DesktopDir & '\Example', $String = 'A total of', $FileToWriteTo = @DesktopDir & '\Example\result.txt' FileWrite($FileToWriteTo, _StringReturn($MainFile, $String)) Func _StringReturn($FileNameLocation, $sSearchString) Local $FileSearch = FileFindFirstFile($FileNameLocation & '\*.doc') Local $sSave = '' While 1 $NextFile = FileFindNextFile($FileSearch) If @error Then ExitLoop $FileRead = FileRead($FileNameLocation & '\' & $NextFile, FileGetSize($FileNameLocation & '\' & $NextFile)) $SnS = StringInStr($FileRead, $sSearchString) If $SnS Then $sSave &= StringMid($FileRead, $SnS + StringLen($sSearchString) + 1) Sleep(10) WEnd FileClose($FileSearch) Return $sSave EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gempie Posted July 6, 2006 Author Share Posted July 6, 2006 Thanx, u helped me out big time 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