SlimShady 1 Posted May 4, 2004 (edited) AutoIt is the best. Thank you for creating this amazing script language and provide it free for everybody.I created a script that searches for files. I'm using the FileFindFirstFile function. There are two problems: - it only searches in the directory you specify and doesn't search through the subfolders.- it only returns the filename and not the full path to the file.It would be great if you would/could add the missing functionality I mentioned above.Thanks again.$SearchWord = InputBox("Search", "Enter a word to search for:" , "", "" , 200, 100) $SearchLocation = FileSelectFolder("Choose a folder to search in:", "", 0) $search = FileFindFirstFile($SearchLocation & "\" & $SearchWord) ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Results = FileOpen(@ScriptDir & "\results.txt", 2) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop FileWriteLine($Results, $file) WEnd ; Close the search handle FileClose($search) FileClose($Results) Run("notepad " & @ScriptDir & "\results.txt") ExitEDIT: The working script I made is available: here. Edited May 5, 2004 by SlimShady Share this post Link to post Share on other sites
Jos 2,165 Posted May 4, 2004 (edited) here's a script posted a while ago to scans through all subdirs and counts files sizes... just modify it to just look for a file....EDIT: Updated to the correct link:http://www.hiddensoft.com/forum/index.php?...findpost&p=6919 Edited May 4, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
ezzetabi 3 Posted May 4, 2004 And if you prefere a full Autoit solution (but a little slower than dir /s/B)http://www.hiddensoft.com/forum/index.php?...parse+subfolder Share this post Link to post Share on other sites
Helge 3 Posted May 4, 2004 - it only returns the filename and not the full path to the file.If you are searching thru a folder, you probably already know the path of the folder.If you don't, then you're way off Share this post Link to post Share on other sites
SlimShady 1 Posted May 4, 2004 (edited) I wanted to make a replacement for Windows filesearch.Ezzetabi made me curious when he said something about: dir /s /bSo I used that; Some statistics:- Whole C-drive listed in a 2,85 MB textfile in about 5 to 10 seconds- i searched for the letters zip; found 376 zip files in exactly 10 seconds (really!)My script:- it's interactive; asks for word (letters) to search for and which drive/folder- It can show you every result in a dialogbox which asks you:"Do you want to locate the file now" <- automatically!OR- It hides itself, searches and shows the results in a textfile when it's doneHere it is, enjoy!EDIT: The working script I made is available: here. Edited May 5, 2004 by SlimShady Share this post Link to post Share on other sites
SlimShady 1 Posted May 4, 2004 Btw, I think Micro$oft should use my method .Much quicker. Share this post Link to post Share on other sites
brett 0 Posted May 4, 2004 I wish i could make something i could actually use... but nice program -Brett Share this post Link to post Share on other sites
tutor2000 0 Posted May 5, 2004 I got this from Larry a while back SearchRecursive(<path with trailinbg slash>, <file search string>) usage: $FileArray = SearchRecursive( "C:\", "*.AU3" ) If Not @error ;$FileArray[] now contains a zero based ;array of files found by SearchRecursive(). ;Use "UBound()" and a "For / Next" loop ;to process the results. EndIf Exit #include "SearchRecursive.au3" ;ADD at the bottom of your script Func SearchRecursive($SR_sRoot,$SR_sSearch) $SR_aReturn="" $SR_iFiles = 0 $SR_sDirList = "" $SR_sFileList = "" While Not @error $SR_sBuffer = FileFindFirstFile($SR_sRoot & "*.*") While Not @error If $SR_sBuffer <> "." And $SR_sBuffer <> ".." Then If StringInStr(FileGetAttrib($SR_sRoot & $SR_sBuffer),"D") Then $SR_sDirList = $SR_sDirList & $SR_sRoot & $SR_sBuffer & "*" EndIf EndIf $SR_sBuffer = FileFindNextFile() Wend $SR_sBuffer = FileFindFirstFile($SR_sRoot & $SR_sSearch) While Not @error $SR_sFileList = $SR_sFileList & $SR_sRoot & $SR_sBuffer & "*" $SR_iFiles = $SR_iFiles + 1 $SR_sBuffer = FileFindNextFile() Wend $SR_iDirDelim = StringInStr($SR_sDirList,"*") If $SR_iDirDelim Then $SR_sRoot = StringLeft($SR_sDirList,$SR_iDirDelim-1) & "\" $SR_sDirList = StringTrimLeft($SR_sDirList,$SR_iDirDelim) Else SetError(1) EndIf Wend If $SR_iFiles Then DIM $SR_aReturn[$SR_iFiles] For $SR_iElement = 0 to $SR_iFiles-1 $SR_iDelimPos = StringInStr($SR_sFileList,"*") $SR_aReturn[$SR_iElement] = StringLeft($SR_sFileList,$SR_iDelimPos-1) $SR_sFileList = StringTrimLeft($SR_sFileList,$SR_iDelimPos) Next Else SetError(1) EndIf Return $SR_aReturn EndFunc Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm Share this post Link to post Share on other sites
SlimShady 1 Posted May 5, 2004 Can someone test the script from Larry (above)? How much time does it take to find something and how many results? I'm currently implementing the ability for multiple keywords in one inputbox. Share this post Link to post Share on other sites
SlimShady 1 Posted May 5, 2004 (edited) I did it. It wasn't very hard to make this script search for multiple words.Example:It tries to match all the words in the full path of the file.If you have a file with the path:C:\Program Files\Test\file.exeIt will match if you enter:.exeprogram file.exefile.exefiles file.exe.exe test fileEDIT: The working script I made is available: here. Edited May 5, 2004 by SlimShady Share this post Link to post Share on other sites