Jump to content

Recommended Posts

Posted

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)

 

Posted
#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)

:)

Posted

Hello,

Thanks for the replay.

But, what if a second subfolders are randomly named (Like, instead "Job_1" -> "123", "abc", "9a9" ) ?
Is there a way to get a list ?

Thanks in advance for your help

 

Posted

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

Posted

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

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
×
×
  • Create New...