TryWare90Days

[RESOLVED] How to exclude subfolders using _FileListToArrayRec

9 posts in this topic

#1 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites



#2 ·  Posted

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

 

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

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")

 

1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted

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

Share this post


Link to post
Share on other sites

#5 ·  Posted

4 hours ago, JLogan3o13 said:

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

 

 

Sorry about that, and thank you for moving it to the right forum.

Share this post


Link to post
Share on other sites

#6 ·  Posted

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")

 

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted

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).

Share this post


Link to post
Share on other sites

#8 ·  Posted

20 hours ago, JLogan3o13 said:

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

 

 

Hi JLogan3013

How do I close this Topic as resolved? 

I have already quoted how it was resolved by Subz and Mikell

Share this post


Link to post
Share on other sites

#9 ·  Posted

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

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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

  • Similar Content

    • 232showtime
      By 232showtime
      is there a limitation for _FileListToArrayRec? I tried to a do _FileListToArrayRec in C: Directory and it takes forever for _ArrayDisplay
    • jguinch
      By jguinch
      In a folder with some files that have no extension (for example the hosts file in C:\Windows\System32\driversetc), FileListToArrayRec does not return the same thing than _FileListToArray if I use *.* as filter :
         _FileListToArray("C:\Windows\System32\driversetc", "*") : returns all files
         _FileListToArray("C:\Windows\System32\driversetc", "*.*") : returns all files
         _FileListToArrayRec("C:\Windows\System32\driversetc", "*") : returns all files
         _FileListToArrayRec("C:\Windows\System32\driversetc", "*.*") : returns only files with extensions
      It seems logic that FileListToArrayRec and FileListToArray should have the same behaviour with the same filter, no ?
      It's not important at all for me, but maybe developers will want to ensure that these two functions react in the same way...
      Edit : sorry if this post is not in the good section. Please move it if needed.