Hi,
Need help in code for multiple files string search.
Ex:
In files: *.txt , *.log
TIA
Multiple in-file string search
Re: Multiple in-file string search
an example
Code: Select all
;---
searchfor=test
extensions:="txt,log"
FileSelectFolder,FD1,%a_desktop%, 2, Pick up a folder with %extensions%
if (fd1="")
return
i=0
Loop,%fd1%\*.*,0,1
{
ALF= %A_LoopFileFullPath%
SplitPath,alf, name, dir, ext, name_no_ext, drive
If ext in %Extensions%
{
aaa=
fileread,aaa,%alf%
Loop,parse,aaa,`n,`r
{
x:= a_loopfield
if x=
continue
if x contains %searchfor%
{
i++
e .= "--Found in file the word = " searchfor . " in = " . alf . "=`r`n" . x . "`r`n"
}
}
}
}
if (i=0)
msgbox, No files with %extensions% found
else
msgbox,%e%
e=
aaa=
exitapp
Re: Multiple in-file string search
Thanks man !garry wrote:an exampleCode: Select all
;--- searchfor=test extensions:="txt,log" FileSelectFolder,FD1,%a_desktop%, 2, Pick up a folder with %extensions% if (fd1="") return i=0 Loop,%fd1%\*.*,0,1 { ALF= %A_LoopFileFullPath% SplitPath,alf, name, dir, ext, name_no_ext, drive If ext in %Extensions% { aaa= fileread,aaa,%alf% Loop,parse,aaa,`n,`r { x:= a_loopfield if x= continue if x contains %searchfor% { i++ e .= "--Found in file the word = " searchfor . " in = " . alf . "=`r`n" . x . "`r`n" } } } } if (i=0) msgbox, No files with %extensions% found else msgbox,%e% e= aaa= exitapp
Who is online
Users browsing this forum: No registered users and 167 guests