Search txt文件中的多重搜索字符串和计数
我无法将该值传递到另一个数组(ArrayValue),因此 我可以跟踪计数Search txt文件中的多重搜索字符串和计数,search,count,autohotkey,Search,Count,Autohotkey,我无法将该值传递到另一个数组(ArrayValue),因此 我可以跟踪计数 我的目标:读取包含所有文本文件的文件夹 搜索文本文件内的数组集(即字符串) 每次匹配时,计数器应增加+1 然后在记事本中按顺序打印结果 前。 CAM_NWID=050RN=10 CAM_NWID=012RW=2 CAM_NWID=016RN=6 CAM_NWID=027RN=1 $^F8:: File := "*.txt" ;can include director
CAM_NWID=050RN=10
CAM_NWID=012RW=2
CAM_NWID=016RN=6
CAM_NWID=027RN=1
$^F8::
File := "*.txt" ;can include directory -- * is wildcard
FileHit := "" ;for reading .txt file
ArrayName:= []
ArrayName[1]:= "CAM_NWID=ESH050RN"
ArrayName[2]:= "CAM_NWID=ESH012RW"
ArrayName[3]:= "CAM_NWID=ESH016RN"
ArrayName[4]:= "CAM_NWID=ESH027RN"
ArrayValue:=[]
ArrayStore:=[]
ArrayValue[j] := A_LoopField
ArrayValue[j, k] := A_LoopReadLine
ArrayCount := 0
InputBox, Directory, Enter the searched directory, Leave empty to use the current directory. Subfolders will
be also searched., , 300, 150
if ErrorLevel
{
MsgBox, Query canceled.
Exit
}
Directory := RegExReplace(Directory, "\\$") ; Removes the leading backslash, if present.
If Directory
{
If(!InStr(FileExist(Directory), "D"))
{
msgbox Invalid directory
Exit
}
StringRight, DirectoryEndingChar, Directory, 1
If(DirectoryEndingChar != "\")
Directory .= "\"
}
Loop, %Directory%%File%, , 1
{
FileRead, FileCheck, %A_LoopFileLongPath%
IfInString, FileCheck, %StringCheck%
FileHit%A_Index% := A_LoopFileLongPath
}
Loop,%Directory%%File%, *.txt, FR
{
for key, val in ArrayName
Loop, Read, %A_LoopFileFullPath%, objects.txt
{
IfInString, A_LoopReadLine, % val
{
StringReplace, CurrentLine, A_LoopReadLine, Name(wstring:64)=
FileAppend, %CurrentLine%`n
vText := CurrentLine
StrReplace(vText, CurrentLine, "", vCount)
;;MsgBox, % CurrentLine" = " .vCount
If (CurrentLine = CurrentLine)
{
ArrayValue[key,k]:=ArrayValue.Insert(key,A_LoopReadLine) ;;this should be the the point where I can pass the value to another specific index in other array
}
ArrayCount+=1
ArrayValue[ArrayCount]
}
}
Loop % ArrayCount
{
element := ArrayValue[A_Index]
MsgBox % "Element Number " . A_Index . " is " . ArrayValue[A_Index]
}
}
return