7 posts in this topic
I have a good handle on how to read a file line by line, and search for a given string.
Basically using, FileOpen, FileReadLine, and StringInStr.
I have been trying to figure out why my search keeps coming back with no match.
For example, if my string line was "Where is Waldy", and I was searching for Waldy that comes back fine.
But in my file, Let's say it is
Where is "Waldy"
So i read that line in and do a search for Waldy, but i comes back with no match since there is quotes around it.
Is there a way to resolve this?
Here is my actual example
The line comes back like this
I'm searching for LineDisp_iSC480, but its coming back with no match due to the quotes.
Thanks in advance, James
Hello, I want to be able to search for multiple strings and if any of the strings are found I want it returned which one it is. I've been able to search for multiple strings using the OR command, but I'm not sure how I am supposed to make it return which of my strings is found. I've given an example below
If StringInStr($html, Batman) OR StringInStr($html, Superman) Then MsgBox(0, "Success", "The string found was: Superman") EndIf So it will search for the two strings and whichever it founds it will return me with. How can I make that work?
#include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $path="C:\Users\rootx\Desktop\Nuova cartella",$mask = "*.jpg;*.png;*.ico",$Pos $FileArr = _FileListToArrayRec($path,$mask,1,1,1,2) For $x = 1 to UBound($FileArr)-1 If $Pos = StringInStr($FileArr[$x],"-") Then ConsoleWrite("------"&$FileArr[$x]&@CRLF) Else ConsoleWrite($FileArr[$x]&@CRLF) FileDelete($FileArr[$x]) EndIf ConsoleWrite($x&@CRLF) Next ConsoleWrite($x-1&@CRLF) I would write a loop that individuals and delete files that contain this feature....
File name-150x100.jpg, or other -SizexSize
But in this case how can I filter properly?
File name 150x100-150x100.jpg
File name -100-150x100.jpg
As always, sorry for my bad english.
here is the code i have
#include <File.au3> #include <String.au3> $file1 = "d:\doppioniautoit\international.txt" FileOpen($file1, 0) $file2 = "d:\doppioniautoit\standard.txt" FileOpen($file2, 0) For $i = 1 to _FileCountLines($file1) $line = FileReadLine($file1, $i) $aExtract = _StringBetween($line, "(", ")") ;MsgBox(0, $line, $aExtract) $itime = TimerInit() For $x = 1 to _FileCountLines($file2) $line2 = FileReadLine($file2, $x) Local $iPosition = StringInStr($line2, $aExtract, 1) ;Local $iPosition = StringRegExp($line2,$aExtract, 0) if $iPosition <> 0 then ;MsgBox(0, "Trovato", $aExtract & " " & $line2) endif ConsoleWrite($line2 & @CRLF) Next ConsoleWrite(@TAB&'Str='&TimerDiff($itime)&' ms'&@lf) MsgBox(0, "TIME", @TAB&'Str='&TimerDiff($itime)&' ms'&@lf) Next FileClose($file1) So, what do i want to do? I try to explain with my poor english Basically, i have 2 text files (see attachments below). They both contains movie titles with Director and Year in this form
Movie Title (Director, Year)
"Standard.txt" contains, mostly, italian titles. "International.txt", as you can image, contains the internationals one. With the script i would like to search for the Director, Year of "international.txt" in the "standard.txt" file.
For example... first row of "international.txt" is "¡Atraco! (Cortés, 2012)". The script takes just the "Cortés, 2012" and it searches for it in the standard. txt file.
The simple code i wrote works... I tried using StringInStr and using StringRegExp.. they both need about 2 minutes and 30 seconds (stringinstr is little faster) to process one row.
I was wondering... is there any other method to make it faster using autoit? Any help would be much appreciated, thx!
Good Morning All,
I'm hoping someone here can work their AutoIT magic
I'm doing a pretty "simple" string search in a HUGE variable.
But I'm doing the basics almost straight out of the Help File...
( sorry, I'm leaving out my main code for privacy reasons )
Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $sFileRead = FileRead($hFileOpen) Local $sEmailPosition01 = StringInStr ($sFileRead, $sEmailAddress ) Everything looks good with my troubleshooting
I ran IsString against $sFileRead and $sEmailAddress and was okay: "The variable is a string"
So then I ran StringLen($sFileRead) and got string length 68352786
Yeah, I know... That's HUGE - But it worked with the older version of AutoIT (upgraded yesterday) v18.104.22.168
Is there an "Excessive" variable I should set?!? lol. Should I search the string a different way maybe?
I know the string is in there... but I'm getting a StringInStr @error : 0 @extended: 0
Please help! Thank you all