Multiple in-file string search

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Noob_Nate
Posts: 11
Joined: 26 Apr 2017, 22:52

Multiple in-file string search

27 Apr 2017, 05:49

Hi,

Need help in code for multiple files string search.

Ex:

In files: *.txt , *.log

TIA :thumbup:
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: Multiple in-file string search

27 Apr 2017, 14:32

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

Noob_Nate
Posts: 11
Joined: 26 Apr 2017, 22:52

Re: Multiple in-file string search

28 Apr 2017, 21:31

garry wrote: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

Thanks man ! :thumbup:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 167 guests