Skitty Posted February 11, 2011 Share Posted February 11, 2011 (edited) I don't know where I originally found this function, but when I had it, it consisted of a complex jump between 2 functions, now its just one and its perfect for noobs looking for a file searching function.Edit: Obsolete, take a look at Melba32's mod'd version for a script thats 20x faster ScanFolder(@WindowsDir,"HelpPane.exe,Explorer.exe,Notepad.exe") Func ScanFolder($SourceFolder,$46) Local $Search Local $File Local $FileAttributes Local $FullFilePath Local $FileCount = 0 $Search = FileFindFirstFile($SourceFolder & "\*.*") While 1 If $Search = -1 Then ExitLoop EndIf $File = FileFindNextFile($Search) If @error Then ExitLoop $FullFilePath = $SourceFolder & "\" & $File $FileAttributes = FileGetAttrib($FullFilePath) If StringInStr($FileAttributes,"D") Then ScanFolder($FullFilePath,$46) Else $460 = StringSplit($FullFilePath,",") $461 = UBound($460) - 1 ToolTip($FullFilePath,0,0) If StringInstr($46,$460[$461]) then MsgBox(0,"Done","MATCH!! " & $460[$461]) EndIf EndIf WEnd FileClose($Search) EndFuncthis should make it a lot easier for noobs to locate a file with autoit, very easy to include in your script.not that I'm not a newbie myself.... Edited February 11, 2011 by System238 Link to comment Share on other sites More sharing options...
guinness Posted February 11, 2011 Share Posted February 11, 2011 (edited) Maybe here >> or But this is the first instance of it appearing with the name ScanFolder and similar syntax >> I thought it best you know, sorry. Nice function though, might have some use for one day. (Haven't Tested!) Edited February 11, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2011 Moderators Share Posted February 11, 2011 System238, Have you actually tried running that code? I think not, because it simply does not work! Take a look at this modified version (which does ) and try and work out why the differences make such a difference. ScanFolder(@WindowsDir,"HelpPane.exe,Explorer.exe,Notepad.exe") Func ScanFolder($SourceFolder, $46) Local $Search Local $File Local $FileAttributes Local $FullFilePath Local $FileCount = 0 $Search = FileFindFirstFile($SourceFolder & "\*.*") If $Search = -1 Then Return While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop If @extended Then ; This is much faster than looking for the "D" attribute ScanFolder($SourceFolder & "\" & $File, $46) Else $460 = StringSplit($SourceFolder & "\" & $File, "\") ; If you split on "," you do NOT get the file name in $460[461] $461 = UBound($460) - 1 ;ToolTip($FullFilePath, 0, 0) If StringInStr($46, $460[$461]) Then MsgBox(0, "Done", "MATCH!! " & $SourceFolder & "\" & $File) EndIf EndIf WEnd FileClose($Search) EndFunc ;==>ScanFolder Please take this as constructive criticism. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Skitty Posted February 11, 2011 Author Share Posted February 11, 2011 (edited) it works on my pc, im using virtual box with win 7 running in it...Edit: lol, your version is like 20x faster.Now I see why, the tool tip is slowing it down a whole lot and removing it improves speed dramatically along with The "@extended" macro you added.Thanks! I had no idea how that worked at first..ScanFolder(@WindowsDir,"HelpPane.exe,Explorer.exe,Notepad.exe") Func ScanFolder($SourceFolder, $46) Local $Search Local $File Local $FileAttributes Local $FullFilePath Local $FileCount = 0 $Search = FileFindFirstFile($SourceFolder & "\*.*") If $Search = -1 Then Return While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop If @extended Then ; This is much faster than looking for the "D" attribute ScanFolder($SourceFolder & "\" & $File, $46) Else $460 = StringSplit($SourceFolder & "\" & $File, "\") ; If you split on "," you do NOT get the file name in $460[461] $461 = UBound($460) - 1 ;ToolTip($SourceFolder & "\" & $File, 0, 0) If StringInStr($46, $460[$461]) Then MsgBox(0, "Done", "MATCH!! " & $SourceFolder & "\" & $File) EndIf EndIf WEnd FileClose($Search) EndFuncIn example, I've enabled the tool tip again in your modified version and its about 5x slower than without it. Edited February 11, 2011 by System238 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2011 Moderators Share Posted February 11, 2011 System238, it works on my pcThen I am extremely surprised. Look at this part of your code: $460 = StringSplit($FullFilePath,",") $461 = UBound($460) - 1 ToolTip($FullFilePath,0,0) If StringInstr($46,$460[$461]) then You are splitting the path on "," which does not normally feature in a full path. So you are most likely to get the following array: [0] 1 [1] whatever $FullFilePath was as StringSplit returns an error. So $460[$461] will be the full path which will never match with the contents of the $46 variable. That is why I said it does not work - certainly it does not work on my machine. Try adding a line like this to your original script just before the ToolTip line and see what you get as a value: ConsoleWrite($460[$461] & @CRLF) I get the full path of every file scanned - best not do this on the Windows folder by the way , it takes a long time to print them all! If you split the path using "\" then you are going to get the file name in the final element of the $460 array and you will get a match if it exists when using StringInStr with the passed list. Again, please do not think I am being picky - but I really do not see how the original can work. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Skitty Posted February 11, 2011 Author Share Posted February 11, 2011 (edited) System238, Then I am extremely surprised. Look at this part of your code: $460 = StringSplit($FullFilePath,",") $461 = UBound($460) - 1 ToolTip($FullFilePath,0,0) If StringInstr($46,$460[$461]) then M23 $460 = StringSplit($FullFilePath,",") Is splitting line [color=#008080][font=monospace][size=2]"HelpPane.exe,Explorer.exe,Notepad.exe"[/size][/font][/color] to search for a match. so thats why it works on my machine but it does take a long time as you said. Yes, I was wrong... any way, now that I'm here, I was wondering. How do I search for a file name match consisting of only part of the file name? I,e - search for all files that begin with "lol", and resulting matches would be "lol1.png" & "lolueb.exe" Edited February 11, 2011 by System238 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2011 Moderators Share Posted February 11, 2011 System238,I wondered if you might have thought you were running the StringInStr the other way round - but then you would only ever have checked the final filename in your checking list. How do I search for a file name match consisting of only part of their name?Take a look at the RecFileListToArray UDF in my sig and you will see how you might match partial names using StringRegExp. Warning: the code does get a bit complex - especially the SRE part - although I have commented it liberally. If you have any questions about any aspect of the UDF then start a new topic in "General Help" and we can discuss it there rather than clog up the "Examples" section. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted February 11, 2011 Share Posted February 11, 2011 (edited) Have a look here >> Though M23 will probably have something better, plus there is their UDF's to have a look at! Edited February 11, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now