Moderators Melba23 Posted February 9, 2012 Moderators Posted February 9, 2012 Hi,As the main author (but see credits in the header) of one of the UDFs under review, I have been watching this thread with interest. I feel I must interject at this point to point out that, as happened in the first post, care must be taken when using similar parameters and code structure for the different UDFs as this can give rise to misleading results. Tlem is quite correct that _RecFileListToArray returns all folders and only matching files when used with the syntax he used in his test script. However, this is exactly what the UDF is designed to do when asked to recursively return "folders and files" as is shown in the logic chart I posted in the UDF thread:$iReturn Mode $sInclude_List $sExclude_List $sExclude_List_Folder Comment applies to applies to applies to $iRecur = 0 Non-recursive search acts as _FileListToArray 0 (Files + Folders) Files + Folders Files + Folders Ignored 1 (Files only) Files only Files only Ignored 2 (Folders only) Folders only Folders only Ignored $iRecur <> 0 0 (Files + Folders) Files only Files only Folders only Searches and returns all folders unless explicitly excluded 1 (Files only) Files only Files only Ignored All folders searched 2 (Folders only) Folders only Folders only IgnoredIf you want to match files and folders you have to call the function twice - once for files and once for folders:#include <RecFileListToArray.au3> If Not FileExists("M:MyTestMyTest.txt") Then DirCreate("M:MyTest") FileWrite("M:MyTestMyTest.txt", "My Test File") EndIf $Path = "M:" $Filter = "MyTest*" $Begin = TimerInit() $aArray1 = _RecFileListToArray($Path, $Filter, 1, 1) ; Look for matching files $Begin = TimerInit() $aArray2 = _RecFileListToArray($Path, $Filter, 2, 1) ; Look for matching folders ConsoleWrite("_RecFileListToArray returned " & $aArray1[0] + $aArray2[0] & " items in " & TimerDiff($Begin) / 1000 & " seconds " & @CRLF) DirRemove("M:MyTest", 1)As to why you need to do this, I made quite clear in the UDF thread that:"I wrote this UDF to meet my particular needs. As such it does exactly what I want - particularly in the sorting routine. I am well aware that there are faster ways to recursively list files but so far I have not found one which does precisely what I require- so I wrote my own UDF."The UDF returns all the folders when asked to return "folders and files" so that when the returned array is sorted (again according to my requirements and not just a simple "one line of code" alphabetical sort) my ChooseFileFolder UDF has the full tree available - remember I wrote the UDF to do what I wanted it to do. If others also find it useful then all well and good, but its primary purpose is to be used in my scripts. Sorry if that sounds selfish - but that is the way it is. As to the size argument, given the size of any compiled AutoIt script I have no problem with the size of any UDF as the increase in the final size of the exe will be barely noticable. Nor, within reason, do I have a problem with speed given AutoIt's less than stellar overall performance. Turning to clarity of code, I do not believe that size and complexity, nor the use of helper functions (sometimes imposed by AutoIt's limitations), necessarily imply a poor code structure. What is important is that the code should be maintainable and offer (reasonably) easy options to amend/upgrade the code if required - that should not be sacrificed to gain speed and/or to reduce the line count. If you have not read the "speed is the root of all evil" thread yet, I recommend it. To end, I personally think it is an excellent thing to have so many recursive search UDFs to choose from depending on the situation. I certainly make no claim that mine is the best in all cases. 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
Tlem Posted February 9, 2012 Posted February 9, 2012 Tlem is quite correct that _RecFileListToArray returns all folders and only matching files when used with the syntax he used in his test script.Yes, but I didn't say only that !^^ Best Regards.Thierry
johnmcloud Posted February 9, 2012 Posted February 9, 2012 Melba,Why your UDF is not a main part of autoit? My personal opinion, It's better of FileListToArray
Belini Posted August 25, 2012 Posted August 25, 2012 I used another method that was faster. #include <String.au3> #include <Array.au3> global $listing = 0 Func list($path = "", $counter = 0) $counter = 0 $path &= '\' Local $list_files = '', $file, $demand_file = FileFindFirstFile($path & '*') If $demand_file = -1 Then Return '' While 1 $file = FileFindNextFile($demand_file) If @error Then ExitLoop If @extended Then If $counter >= 10 Then ContinueLoop $listing &= $path & $file & "|" list($path & $file, $counter + 1) Else $listing &= $path & $file & "|" EndIf WEnd Return $listing FileClose($demand_file) EndFunc -> -> List_files returned 42264 items in 0.42 seconds. -> FileListToArrayRecursive returned 42264 items in 0.92 seconds. -> FileListToArray3 returned 42264 items in 1.84 seconds. -> RecFileListToArray returned 42264 items in 1.81 seconds. -> FileListToArrayEx returned 42264 items in 0.88 seconds. -> FileListToArrayPlus returned 42264 items in 0.75 seconds. -> FileListTreeToArray returned 42264 items in 2.66 seconds.Speed Test.rar My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
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