Skip to content

Instantly share code, notes, and snippets.

@grayatrox
Created July 15, 2013 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grayatrox/5997933 to your computer and use it in GitHub Desktop.
Save grayatrox/5997933 to your computer and use it in GitHub Desktop.
results := search("notepad","C:\Windows") ; This is something I know everyone will have
for result in results
msgbox Result: %result%
Return
search(searchTerm, searchDirectory = "C:", filePattern = "*.*", recursive = 1) {
results := {}
SplitPath, searchTerm , OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
if (!OutExtension)
{
search := searchDirectory "\" filePattern
} Else {
search := searchDirectory
}
Progress, R0-100 H125 y10,,Searching...
progress := 0
Loop, %search%, 0, %recursive%
{
progress += 0.1
Progress, %progress%, %A_LoopFileName%, Searching: %searchDirecory%, Current File:
If (InStr(A_LoopFileName,searchTerm))
{
results.Insert(A_LoopFileFullPath)
}
if (progress > 100)
progress := 0
}
return, results
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment