Thelaughedking Posted November 6, 2021 Share Posted November 6, 2021 (edited) Hi I am wanting to run _FileListToArrayRec in the background and check its progress (mainly I just want to know its progress). I am using _FileListToArrayRec to search for files of a given type and upon searching the entire C:\ drive I see that the process takes quite some time. I was inspired by this project as windows 11's files search function is currently broken for me (06/11/2021). Any ideas how to run this function in the background and get the progress? I was thinking something along the lines of the InetGet ( "URL", "filename" [, options = 0 [, background = 0]] ) Background function, but I see in the help file the _FileListToArrayRec function does not have such a thing, does this mean it is not possible? Many thanks in advance, Jacob Global $version = "1.0.0.0" ;A script that counts how many .au3 files are in a folder and sub-folders #include <File.au3> Global $FileType = InputBox("File Type","Input the file type you would like to count."&@CRLF&"* = All types","*") If @error=1 Then Exit If $FileType="" Then $FileType = "*" Global $FolderStart = FileSelectFolder("Select a folder to cound files in...",@HomeDrive) If @error=1 Then Exit ;$Files = _FileListToArray($FolderStart,"*.au3",1) $Files = _FileListToArrayRec($FolderStart,"*."&$FileType,1,1,1) $BoolFiles = True If @error <> 0 Then $BoolFiles = False $output="Files:" For $i = 1 to $Files[0] step 1 $output=$output&@CRLF&$Files[$i] Next MsgBox(0,$Files[0]&" FIle have been found.",$output) Edited November 6, 2021 by Thelaughedking more details Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2021 Share Posted November 6, 2021 Not possible with _FileListToArrayRec. You would need to use/create the code to add some checkpoints inside it. For example you could count the number of folders from the starting folder and then calculate the number of folders searched to have a progress percentage. Thelaughedking 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...
Thelaughedking Posted November 7, 2021 Author Share Posted November 7, 2021 Thank you, this is a very good suggestion. I might look into this, we will see if I get around to it, I'm working on a tcp server so that takes priority at the moment Link to comment Share on other sites More sharing options...
Thelaughedking Posted November 7, 2021 Author Share Posted November 7, 2021 19 hours ago, Nine said: Not possible with _FileListToArrayRec. You would need to use/create the code to add some checkpoints inside it. For example you could count the number of folders from the starting folder and then calculate the number of folders searched to have a progress percentage. Thank you, this is a very good suggestion. I might look into this, we will see if I get around to it, I'm working on a tcp server so that takes priority at the moment Link to comment Share on other sites More sharing options...
BinaryBrother Posted November 7, 2021 Share Posted November 7, 2021 It really wouldn't be all that difficult... Here's the original. Func _FileListToArray($sFilePath, $sFilter = "*", $iFlag = $FLTA_FILESFOLDERS, $bReturnPath = False) Local $sDelimiter = "|", $sFileList = "", $sFileName = "", $sFullPath = "" ; Check parameters for the Default keyword or they meet a certain criteria $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+$", "") & "\" ; Ensure a single trailing backslash If $iFlag = Default Then $iFlag = $FLTA_FILESFOLDERS If $bReturnPath Then $sFullPath = $sFilePath If $sFilter = Default Then $sFilter = "*" ; Check if the directory exists If Not FileExists($sFilePath) Then Return SetError(1, 0, 0) If StringRegExp($sFilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0) If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 0, 0) Local $hSearch = FileFindFirstFile($sFilePath & $sFilter) If @error Then Return SetError(4, 0, 0) While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If ($iFlag + @extended = 2) Then ContinueLoop $sFileList &= $sDelimiter & $sFullPath & $sFileName WEnd FileClose($hSearch) If $sFileList = "" Then Return SetError(4, 0, 0) Return StringSplit(StringTrimLeft($sFileList, 1), $sDelimiter) EndFunc ;==>_FileListToArray So... You'll need to grab a total count of files from the directory that you're indexing, and then count them off... Something like DirGetSize, maybe? This is dirty, but it gives you a good starting point. Take note of lines 15 & 21. Func _FileListToArray($sFilePath, $sFilter = "*", $iFlag = $FLTA_FILESFOLDERS, $bReturnPath = False) Local $sDelimiter = "|", $sFileList = "", $sFileName = "", $sFullPath = "" ; Check parameters for the Default keyword or they meet a certain criteria $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+$", "") & "\" ; Ensure a single trailing backslash If $iFlag = Default Then $iFlag = $FLTA_FILESFOLDERS If $bReturnPath Then $sFullPath = $sFilePath If $sFilter = Default Then $sFilter = "*" ; Check if the directory exists If Not FileExists($sFilePath) Then Return SetError(1, 0, 0) If StringRegExp($sFilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0) If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 0, 0) $Return = DirGetSize($sFilePath, 1) $TotalFiles = $Return[1] Local $hSearch = FileFindFirstFile($sFilePath & $sFilter) If @error Then Return SetError(4, 0, 0) While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop $TotalFiles -= 1 TrayTip("Info", "Files Remaining: " & $TotalFiles, 10) If ($iFlag + @extended = 2) Then ContinueLoop $sFileList &= $sDelimiter & $sFullPath & $sFileName WEnd FileClose($hSearch) If $sFileList = "" Then Return SetError(4, 0, 0) Return StringSplit(StringTrimLeft($sFileList, 1), $sDelimiter) EndFunc ;==>_FileListToArray SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 7, 2021 Moderators Share Posted November 7, 2021 BinaryBrother, The question refers to _FileListToArrayRec, not FileListToArray - which means that the problem is orders of magnitude bigger. Thelaughedking, As the author of the _FileListToArrayRec function I would counsel against trying to get any form of internal count of files to produce a percentage value. For any such count to have a sensible value, you would essentially need to run the internal code of the UDF twice - once to get the count of files to test and then again to actually test them. And as you have discovered, working through a big folder tree in AutoIt can take quite some time - so doing it twice would basically double the execution time. Hence why such a functionality is not inside the code. Using DirGetSize to get a file count is equally futile as the number returned is the total files in the tree and not those which will be searched for by the UDF, which can include/exclude folders within the tree and so could have to deal with a significantly smaller number of files. My advice has always been to use a marquee progress bar to indicate that something is happening so the the user does not come to believe that the whole process has stalled. 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...
BinaryBrother Posted November 7, 2021 Share Posted November 7, 2021 Another Doh!, in 24 hours. I was attempting to provide some useful support, while I was here asking questions and failed to note the details of OP's post. That being said... I still have another suggestion! Try taking a peek at this thread, where a few of the old dogs suggest different ways for dealing with this problem! SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Thelaughedking Posted November 19, 2021 Author Share Posted November 19, 2021 On 11/8/2021 at 3:06 AM, BinaryBrother said: It really wouldn't be all that difficult... Here's the original. Func _FileListToArray($sFilePath, $sFilter = "*", $iFlag = $FLTA_FILESFOLDERS, $bReturnPath = False) Local $sDelimiter = "|", $sFileList = "", $sFileName = "", $sFullPath = "" ; Check parameters for the Default keyword or they meet a certain criteria $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+$", "") & "\" ; Ensure a single trailing backslash If $iFlag = Default Then $iFlag = $FLTA_FILESFOLDERS If $bReturnPath Then $sFullPath = $sFilePath If $sFilter = Default Then $sFilter = "*" ; Check if the directory exists If Not FileExists($sFilePath) Then Return SetError(1, 0, 0) If StringRegExp($sFilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0) If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 0, 0) Local $hSearch = FileFindFirstFile($sFilePath & $sFilter) If @error Then Return SetError(4, 0, 0) While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If ($iFlag + @extended = 2) Then ContinueLoop $sFileList &= $sDelimiter & $sFullPath & $sFileName WEnd FileClose($hSearch) If $sFileList = "" Then Return SetError(4, 0, 0) Return StringSplit(StringTrimLeft($sFileList, 1), $sDelimiter) EndFunc ;==>_FileListToArray So... You'll need to grab a total count of files from the directory that you're indexing, and then count them off... Something like DirGetSize, maybe? This is dirty, but it gives you a good starting point. Take note of lines 15 & 21. Func _FileListToArray($sFilePath, $sFilter = "*", $iFlag = $FLTA_FILESFOLDERS, $bReturnPath = False) Local $sDelimiter = "|", $sFileList = "", $sFileName = "", $sFullPath = "" ; Check parameters for the Default keyword or they meet a certain criteria $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+$", "") & "\" ; Ensure a single trailing backslash If $iFlag = Default Then $iFlag = $FLTA_FILESFOLDERS If $bReturnPath Then $sFullPath = $sFilePath If $sFilter = Default Then $sFilter = "*" ; Check if the directory exists If Not FileExists($sFilePath) Then Return SetError(1, 0, 0) If StringRegExp($sFilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0) If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 0, 0) $Return = DirGetSize($sFilePath, 1) $TotalFiles = $Return[1] Local $hSearch = FileFindFirstFile($sFilePath & $sFilter) If @error Then Return SetError(4, 0, 0) While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop $TotalFiles -= 1 TrayTip("Info", "Files Remaining: " & $TotalFiles, 10) If ($iFlag + @extended = 2) Then ContinueLoop $sFileList &= $sDelimiter & $sFullPath & $sFileName WEnd FileClose($hSearch) If $sFileList = "" Then Return SetError(4, 0, 0) Return StringSplit(StringTrimLeft($sFileList, 1), $sDelimiter) EndFunc ;==>_FileListToArray Many Many thanks for you time @BinaryBrother I will try it out when I get a moment! Thanks again looks great 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