Jump to content

_FileListToArrayRec and subfolders filter


 Share

Recommended Posts

Hi,

Is there any way to set up folder filter in _FileListToArrayRec() to get following array ?

Folder structure:
C:.
├───Folder_1
│   └───Job_1
│       └───SUBFOLDER_1
├───Folder_2
│   └───Job_1
│       └───SUBFOLDER_1
└───Trash

 

And what i want to have in array is only:

C:\Temp\Folder_1\Job_1
C:\Temp\Folder_2\Job_2

 

Any help is going to be appreciated.

Bye

#include <File.au3>
#include <Array.au3>

Local $dir="C:\Temp"

DirCreate("C:\Temp\TRASH")
DirCreate("C:\Temp\Folder_1\Job_1\SUBFOLDER_1")
DirCreate("C:\Temp\Folder_2\Job_1\SUBFOLDER_1")

$FOLDER_ARRAY = _FileListToArrayRec($dir, "*", $FLTAR_FOLDERS, -1, $FLTAR_FASTSORT, $FLTAR_FULLPATH)

_ArrayDisplay($FOLDER_ARRAY)

 

Link to comment
Share on other sites

#include <File.au3>
#include <Array.au3>

Local $dir="C:\Temp"

DirCreate("C:\Temp\TRASH")
DirCreate("C:\Temp\Folder_1\Job_1\SUBFOLDER_1")
DirCreate("C:\Temp\Folder_2\Job_1\SUBFOLDER_1")

$FOLDER_ARRAY = _FileListToArrayRec($dir, "*", $FLTAR_FOLDERS, -1, $FLTAR_FASTSORT, 1)
;_ArrayDisplay($FOLDER_ARRAY)

Local $res[0]
For $i = 1 to $FOLDER_ARRAY[0]
    (StringInStr($FOLDER_ARRAY[$i], "\") <> 0) ? _ArrayAdd($res, $dir & "\" & $FOLDER_ARRAY[$i]) : 0
Next
_ArrayDisplay($res)

:)

Link to comment
Share on other sites

Thank you, that was my first solution as well but, the speed is "quite slow" i thought it would be faster with the some filter setup.

Maybe someone knows other solution? There must be a (fast) way to get a list of subfolder structure up/from to a certain level, or not ?

Thanks

Link to comment
Share on other sites

Try not sorting in the _FileListToArrayRec call, but after.  This may speed it up, depending on how large the path tree is.  From the help file for _FileListToArrayRec.  

Quote

Sorting the results will significantly increase the time required for the UDF to return the array.

 

Adam

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...