myspacee Posted May 14, 2011 Share Posted May 14, 2011 hello to all, i need to read some lines in 190 files. post some code that have error but can't find where: ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("C:\temp\*.txt) ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $file_read = FileOpen($file, 0) $line_01 = FileReadLine($file, 1) msgbox(0, "This is sfirst line of : " & $file, $line_01) FileClose($file) WEnd ; Close the search handle FileClose($search) in this example sscript should read first line for every file, but doesn't. anyone can correct me please ? thank you, m. Link to comment Share on other sites More sharing options...
wakillon Posted May 14, 2011 Share Posted May 14, 2011 Try this ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("C:\temp\*.txt" ) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop ConsoleWrite ( "$file : " & $file & @Crlf ) $line_01 = FileReadLine ( 'c:\' & $file, 1 ) ConsoleWrite ( "$line_01 : " & $line_01 & @Crlf ) msgbox ( 0, '', "This is sfirst line of : " & $file & @crlf & $line_01 ) FileClose($file) WEnd ; Close the search handle FileClose($search) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
hannes08 Posted May 14, 2011 Share Posted May 14, 2011 Hi myspacee, if you need to read more than 1 line per file, I suggest to use _FileReadToArray instead of FileReadLine() because it's faster. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] 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