HeyTom Posted April 30, 2020 Share Posted April 30, 2020 (edited) Hi, I have see many complex function for file finding, like _RecFileListToArray and many many others Assuming i want to search a single file, without wildcard, without excluding folder or any other things, in a folder with his subfolders (is a network folder like \\192.168.1.1\Path but i don't thing change something) what i can use? Fastest as possible, is better Thanks Edited April 30, 2020 by HeyTom Link to comment Share on other sites More sharing options...
Nine Posted April 30, 2020 Share Posted April 30, 2020 Do you want to find all copies of this single file (some maybe older, smaller, etc.), or do you want to find only the first file and exit recursion ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
careca Posted April 30, 2020 Share Posted April 30, 2020 (edited) I would go with FileFindFirstFile and FileFindNextFile $Folder = @ScriptDir & '\' $search = FileFindFirstFile($Folder & "file*.exe") ;* serves as wildcard If $search = -1 Then MsgBox(16, "Error", "No files/directories matched the search pattern") Exit Else Local $file = FileFindNextFile($search) $Exe = $Folder & $file EndIf ShellExecuteWait($Exe, "/s") Exit Edited April 30, 2020 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
HeyTom Posted April 30, 2020 Author Share Posted April 30, 2020 (edited) 36 minutes ago, Nine said: Do you want to find all copies of this single file (some maybe older, smaller, etc.), or do you want to find only the first file and exit recursion ? First, just want to know if exist or not in the folder and his subfolder @careca In need to search inside the subfolder Edited April 30, 2020 by HeyTom Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 30, 2020 Moderators Share Posted April 30, 2020 HeyTom, The UDF you quote has been deprecated for some time and the code incorporated in to the standard includes - have you tried using _FileListToArrayRec? Is it really too slow for you? 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...
Nine Posted April 30, 2020 Share Posted April 30, 2020 (edited) After testing a few of my scripts, the fastest seems to be this one, if it can find the file sooner than later (it will return almost instantly) : Local $hTimer = TimerInit (), $sFound _FindFirstFile2 ("C:\Apps", "File searched.txt") MsgBox ($MB_SYSTEMMODAL, $sFound, TimerDiff($hTimer)) Func _FindFirstFile2($sFolder, $sFile) If $sFound Then Return ; ConsoleWrite("Folder Name = " & $sFolder & @CRLF) Local $hFile = FileFindFirstFile ($sFolder & "\" & $sFile) If $hFile <> -1 Then $sFound = $sFolder Return EndIf Local $aList = _FileListToArray ($sFolder, "*", $FLTA_FOLDERS, True) If @error Then Return For $i = 1 to $aList[0] _FindFirstFile2 ($aList[$i], $sFile) Next EndFunc But if the file is found later than sooner, then _FileListToArrayRec is a little faster (about 2x times). Conclusion, either use my code, or the best solution would be to modify the UDF to return instantly on the first hit (but that will require more work for you) Edited April 30, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted April 30, 2020 Share Posted April 30, 2020 Here an example with the standard function _FileListToArrayRec. Quick enough to satisfy me . #include <File.au3> Global $hTimer = TimerInit(), $bFileFound $bFileFound = _FindFile(@ScriptDir & "\", "FindFileTestfile.txt") MsgBox(4096, "Result", "file found = " & $bFileFound & @CRLF & _ "search time = " & StringFormat("%12.2f ms", TimerDiff($hTimer))) Func _FindFile($sFolder, $sFile) Local $aList = _FileListToArrayRec($sFolder, $sFile, $FLTAR_FILES , $FLTAR_RECUR) If @error Then Return False Return True EndFunc "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Nine Posted May 1, 2020 Share Posted May 1, 2020 @Musashi As I said, if the file is found early (I deliberately search a file with rapid hit), my code found it in less than 2 ms while _FileListToArrayRec took about 400ms, so about 200 times faster. On the other end, I managed to search a file at the very end, mine took 800 ms while _FileListToArrayRec took the same 400 ms, so about 2 times slower. It is a bit of a gambling, you can win lots, or you could loose a bit, what would you choose ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted May 1, 2020 Share Posted May 1, 2020 (edited) 9 hours ago, Nine said: As I said, if the file is found early (I deliberately search a file with rapid hit) [...] It is a bit of a gambling, you can win lots, or you could loose a bit, what would you choose ? Hi Nine ! Your runtime analysis and code variations are absolutely fine. My snippet should only show the OP the simple standard way, without having to modify the UDF in the case of _FileListToArrayRec. It was by no means intended as a criticism or improvement of your solution . 17 hours ago, HeyTom said: Assuming i want to search a single file [...] in a folder with his subfolders [...] what i can use? Fastest as possible, is better Sometimes understandability and simplicity are better than speed . As long as you do not have to search many files, 200 to 300 ms are not significant. Edited May 1, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Nine Posted May 1, 2020 Share Posted May 1, 2020 It was just to let know how my benchmarks performed under the same folder tree. I thought it was interesting to reveal the difference. Musashi 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2020 Moderators Share Posted May 1, 2020 Nine, Interesting benchmarks, thanks for testing. I spent a lot of time trying to optimise that code for speed. HeyTom, Within the _FileListToArrayRec UDF there is a possibility to limit the level of sub-folders to be searched below the initial path, which obviously makes it much faster as it removes the deeper searches and so result in a significant reduction of execution time. Perhaps that might be useful to you. 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...
rudi Posted May 7, 2020 Share Posted May 7, 2020 (edited) In case you have administrative rights to the server presenting the network share, and you often have just to find some file, then I'd like to mention to take a look at a tool called "EVERYTHING". In short: Everything is indexing all local NTFS drive's MFT (Master File Table) Search results are presented literally instantly It's possible to activate a feature called "ETP Server" on the file server When done so, then you can start everything on your WS to connect to that remote Windows server, that's running Everything with "ETP Server activated". You will need admin rights to the file server! Then you get the search results not really instantly, but still extremly fast. E.g. for some file server I take care of with over 10 Million files the inital load of the "Remote Everything GUI" on my WS takes 2 or 3 seconds. The search results itself are still presented with just far less then 500ms delay. Edited May 7, 2020 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! 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