Jump to content

[RESOLVED] How to exclude subfolders using _FileListToArrayRec


Recommended Posts

Can anybody please help about how to exclude subfolders with the _FileListToArrayRec function?

According to the F1 helpfile this should create an array including subfolders, where subfolders like Include should be excluded:

    ; And now ignoring the "Include" folder
    #include <Array.au3>
    $aArray = _FileListToArrayRec($sAutoItDir, "*||include", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "No 'Include' folder")

But it doesn't work if I change it to:

    ; And now ignoring the "Windows" folder
    #include <Array.au3>
    $aArray = _FileListToArrayRec("C:\", "*||Windows", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "No 'Windows' folder")


But this is what I really want to do: Create an array only with all filenames including full path, for all root and subfolders, sorted, but without system and hidden files, and without the following root and subfolders: C:\ $Recycle.Bin, C:\ Program Files, C:\ Program Files (x86) , C:\Users, C:\Windows

#include <Array.au3>
Global $aArray = _FileListToArrayRec("C:\", "*||$Recycle.Bin||" & Chr(34) & "Program Files" & Chr(34) & "||" & Chr(34) & "Program Files (x86)" & Chr(34) & "||Users||Windows", $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH)
_ArrayDisplay($aArray, "_ArrayDisplay is only showing the first 65.525 rows of the $aArray")
;    Please note: $aArray[0] shows 284.868 rows created.

Please note, that my code above can be compiled without any syntax errors, and can run without any syntax errors, but the created array doesn't exclude any of the wanted subfolders.

 

 

Edited by TryWare90Days
[RESOLVED]
Link to comment
Share on other sites

  • Moderators

Moved to the correct forum, as the DEV forum very clearly states:

Quote

Do not create AutoIt-related topics here, use the AutoIt General Help and Support

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

This works well on my XP

#include <Array.au3>
#include <File.au3>
Global $aArray = _FileListToArrayRec("C:\", _ 
    "*||$Recycle.Bin;Program Files;Documents and Settings;Windows", _ 
    $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, _ 
    $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH)
_ArrayDisplay($aArray, "_ArrayDisplay is only showing the first 65.525 rows of the $aArray")

 

Link to comment
Share on other sites

3 hours ago, mikell said:

This works well on my XP

#include <Array.au3>
#include <File.au3>
Global $aArray = _FileListToArrayRec("C:\", _ 
    "*||$Recycle.Bin;Program Files;Documents and Settings;Windows", _ 
    $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, _ 
    $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH)
_ArrayDisplay($aArray, "_ArrayDisplay is only showing the first 65.525 rows of the $aArray")

 

 

It also works on my Windows 7, but I still see the 4 "excluded" subfolders in my $aAarray.

Do you see the 4 "excluded" subfolders in your XP

Link to comment
Share on other sites

Tested on Windows 10 x64 works fine, did you change the folders for Windows 7 x64?

#include <Array.au3>
#include <File.au3>
Global $aArray = _FileListToArrayRec("C:\", "*||$Recycle.Bin;Program Files;Program Files (x86);Users;Windows", _
    $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, _
    $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH)
_ArrayDisplay($aArray, "_ArrayDisplay is only showing the first 65.525 rows of the $aArray")

 

Link to comment
Share on other sites

14 hours ago, Subz said:

Tested on Windows 10 x64 works fine, did you change the folders for Windows 7 x64?

#include <Array.au3>
#include <File.au3>
Global $aArray = _FileListToArrayRec("C:\", "*||$Recycle.Bin;Program Files;Program Files (x86);Users;Windows", _
    $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, _
    $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH)
_ArrayDisplay($aArray, "_ArrayDisplay is only showing the first 65.525 rows of the $aArray")

 

 

Thank you Subz, and actually also Mikell (but I didn't study Mikell's answer good enough), you both solved the issue.

I tried with no luck to use: 
Global $aArray = _FileListToArrayRec("C:\", "*||$Recycle.Bin||" & Chr(34) & "Program Files" & Chr(34) & "||" & Chr(34) & "Program Files (x86)" & Chr(34) & "||Users||Windows", $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH)

But after changing it, it works perfect as I needed because I changed the rest of the || to ; and removed the Chr(34) between the programs folders:

Global $aArray = _FileListToArrayRec("C:\", "*||$Recycle.Bin;Program Files;Program Files (x86);Users;Windows", $FLTAR_FILES+$FLTAR_NOSYSTEM+$FLTAR_NOHIDDEN, $FLTAR_RECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH)

And actually, it runs in a very few seconds before the _ArrayDisplay() is shown.

BTW: Subz, on my Windows X64, the program folder is C:\Program Files, and all x86 installations are created in the C:\Program Files (x86).

Link to comment
Share on other sites

  • Moderators

Just edit the first post in the thread and add [RESOLVED] in front of your title.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

×
×
  • Create New...