ZTree.com  | ZEN  | About...  

 Index   Back

[OT] BAT converted to AutoHotkey   [OT]

By: Slobodan Vujnovic   Homepage   France  
Date: Jan 22,2023 at 23:08
In Response to: [OT] Example BAT script (Slobodan Vujnovic)

; Set the search string and the directory to search in
search := "search_string"
dir := A_ScriptDir

; Check if the search string is empty
if (search = "")
{
MsgBox, Please provide a search string.
Exit
}

; Get a list of all .txt files in the directory
fileList := []
Loop, %dir%\*.txt, 0, 1
{
fileList.Push(A_LoopFileFullPath)
}

; Iterate through the list of files and search for the string
for file in fileList
{
content := FileRead(file)
if (content = "")
continue
MsgBox, %file%
if (InStr(content, search))
MsgBox, The string "%search%" is present in the file "%file%".
}

30 views      
 

Messages in this Thread

 
96,194 Postings in 12,153 Threads, 350 registered users, 27 users online (1 registered, 26 guests)
Index | Admin contact |   Forum Time: Jan 27, 2023 - 2:13 am UTC  |  Hits:53,204,519  (1,752 Today )
RSS Feed