Sign in to follow this  
Followers 0
speedy6

Exclude problem _FileListToArray3

16 posts in this topic

Hi, i'm using _FileListToArray3

But i've a problem with it.

When i use this:

local $path = "c:\",$filter = "*.exe",$sExclude="c:\Windows\*|Backup|MSOCache"

$ar_Array = _FileListToArray3 ($path, $filter, 0, 1, 1,$sExclude)

_ArrayDisplay($ar_Array, "File List")

I stil get files within the c:\windows folder, but I excuded them...how can I solve that?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Hi,

My memory is that Exclude works on folder names only if the flag is for a recursive list of folders, I fear; not sure if i can change that easily, or want to? [and I have to go back and check if it is true]

[Whether I'm right or not, ] Workaround, I'm afraid [-not- tested just now] is to do 2 stages;

1. Call the function with flag set to "2", to get recursive list of the folders.

$sPath1 = "c:\",  $filter = "*" ,  $Exclude = "windows|backup|MSOCache"oÝ÷ Ûe,zØZµªëk(§jZ(¦ÚjY_ºw-ðØ_¨,zÚ®¢Ýjº_¢·âë(¢æú.×b­ç-¢¼§¢zÞrêì÷¥É«­¢+ØÀÌØíÍAÑ ÄômÉÉå%ѵt°ÀÌØí¥±ÑÈôÅÕ½Ð쨹áÅÕ½Ðì°ÀÌØíá±ÕôÅÕ½ÐìÅÕ½Ð

Probably no slower, as recursive component only used once.

Best, Randall

Edited by randallc

Share this post


Link to post
Share on other sites

Like this?:

local $path = "c:\",$filter = "*.exe",$sExclude="Windows|Backup|MSOCache"

$ar_Array = _FileListToArray3 ($path, $filter, 2, 1, 1,$sExclude)

$ar_Array2 = _FileListToArray3 ($ar_Array, $filter, 1, 1, 1,"")

_ArrayDisplay($ar_Array2, "File List")

That give's me nothing, he doesn't find a thing...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Like this?:

local $path = "c:\",$filter = "*.exe",$sExclude="Windows|Backup|MSOCache"

$ar_Array = _FileListToArray3 ($path, $filter, 2, 1, 1,$sExclude)

$ar_Array2 = _FileListToArray3 ($ar_Array, $filter, 1, 1, 1,"")

_ArrayDisplay($ar_Array2, "File List")

That give's me nothing, he doesn't find a thing...

Hi, No, there won't be any directories returned if you have your folder filter with "*.exe" rather than "*"

then you will need to do aloop on that array and save data from each array.

I can make it easier with this modification, so a string is returned each time;

#include-once
;~ #include"_ArrayDisplaySortV.au3"
;~ #include "ArrayDupes8.au3"
#include<FileListToArray3.au3>
#include<Array.au3>

Local $sArray2,$ar_Array = _FileListToArray3("c:\", "*", 2, 1, 1, "windows|backup|MSOCache"); $Flag = 2, $Recurse = 1, $BasDir = 1;,$sPath1 = @ScriptDir
;~ _ArrayDisplay($ar_Array,"$ar_Array Folders")

For $i = 1 To UBound($ar_Array) - 1
    $sArray2 &= _FileListToArray3($ar_Array[$i], "*.exe", 1, 0, 1, "", 2);$Flag = 1, $Recurse = 0, $BasDir = 1, $sExclude = ""
Next
$ar_Array = StringSplit(StringTrimRight($sArray2,1), "*", 1)
_ArrayDisplay($ar_Array,"$ar_Array Files")
Best, randall Edited by randallc

Share this post


Link to post
Share on other sites

Hi, No, there won't be any directories returned if you have your folder filter with "*.exe" rather than "*"

then you will need to do aloop on that array and save data from each array.

I can make it easier with this modification, so a string is returned each time;

#include-once
;~ #include"_ArrayDisplaySortV.au3"
;~ #include "ArrayDupes8.au3"
#include<FileListToArray3.au3>
#include<Array.au3>

Local $sArray2,$ar_Array = _FileListToArray3("c:\", "*", 2, 1, 1, "windows|backup|MSOCache"); $Flag = 2, $Recurse = 1, $BasDir = 1;,$sPath1 = @ScriptDir
;~ _ArrayDisplay($ar_Array,"$ar_Array Folders")

For $i = 1 To UBound($ar_Array) - 1
    $sArray2 &= _FileListToArray3($ar_Array[$i], "*.exe", 1, 0, 1, "", 2);$Flag = 1, $Recurse = 0, $BasDir = 1, $sExclude = ""
Next
$ar_Array = StringSplit(StringTrimRight($sArray2,1), "*", 1)
_ArrayDisplay($ar_Array,"$ar_Array Files")
Best, randall

$sArray2 &= _FileListToArray3($ar_Array[$i], "*.exe", 1, 0, 1, "", 2);

Get error on that, isn't it:

$sArray2 &= _FileListToArray3($ar_Array[$i], "*.exe", 1, 0, 1, "");

But even with that I get an empty array...

Share this post


Link to post
Share on other sites

I can make it easier with this modification, so a string is returned each time;

Best, randall

Hi,

I don't think you have used the modified file I posted in the zip in that post; that is why the "2" is there... The new version then returns a string, otherwise you are trying to add arrays..

Best, Randall

Share this post


Link to post
Share on other sites

jah you where wright. But still an empty array.

#include-once

#include<FileListToArray3.au3>

;#include<_FileListToArrayNew2h.au3>

#include<Array.au3>

Local $sArray2,$ar_Array = _FileListToArray("c:\", "*", 2, 1, 1, "windows|backup|MSOCache"); $Flag = 2, $Recurse = 1, $BasDir = 1;,$sPath1 = @ScriptDir

;~ _ArrayDisplay($ar_Array,"$ar_Array Folders")

For $i = 1 To UBound($ar_Array) - 1

$sArray2 &= _FileListToArray($ar_Array[$i], "*.exe", 1, 0, 1, "", 2);$Flag = 1, $Recurse = 0, $BasDir = 1, $sExclude = ""

Next

$ar_Array = StringSplit(StringTrimRight($sArray2,1), "*", 1)

_ArrayDisplay($ar_Array,"$ar_Array Files")

Share this post


Link to post
Share on other sites

jah you where wright. But still an empty array.

#include-once

#include<FileListToArray3.au3>

;#include<_FileListToArrayNew2h.au3>

#include<Array.au3>

Local $sArray2,$ar_Array = _FileListToArray("c:\", "*", 2, 1, 1, "windows|backup|MSOCache"); $Flag = 2, $Recurse = 1, $BasDir = 1;,$sPath1 = @ScriptDir

;~ _ArrayDisplay($ar_Array,"$ar_Array Folders")

For $i = 1 To UBound($ar_Array) - 1

$sArray2 &= _FileListToArray($ar_Array[$i], "*.exe", 1, 0, 1, "", 2);$Flag = 1, $Recurse = 0, $BasDir = 1, $sExclude = ""

Next

$ar_Array = StringSplit(StringTrimRight($sArray2,1), "*", 1)

_ArrayDisplay($ar_Array,"$ar_Array Files")

Hi,

I don't understand what you are doing here; where did "_FileListToArray" come from?, instead of "_FileListToArray3"; do you know you can just copy the script from the screen in the forum??

Randall

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Yeah I did that.

But then I get the error can't find function _filelisttoarray3

with this:

#include-once

#include<FileListToArray.au3>

#include<Array.au3>

Local $sArray2,$ar_Array = _FileListToArray3("c:\", "*", 2, 1, 1, "windows|backup|MSOCache"); $Flag = 2, $Recurse = 1, $BasDir = 1;,$sPath1 = @ScriptDir

;~ _ArrayDisplay($ar_Array,"$ar_Array Folders")

For $i = 1 To UBound($ar_Array) - 1

$sArray2 &= _FileListToArray3($ar_Array[$i], "*.exe", 1, 0, 1, "", 2);$Flag = 1, $Recurse = 0, $BasDir = 1, $sExclude = ""

Next

$ar_Array = StringSplit(StringTrimRight($sArray2,1), "*", 1)

_ArrayDisplay($ar_Array,"$ar_Array Files")

Edited by speedy6

Share this post


Link to post
Share on other sites

Yeah I did that.

But then I get the error can't find function _filelisttoarray3

#include<FileListToArray.au3>

Hi,

So again, you have not included the correct last UDF!

Copy the script from post#5; It has "#include<FileListToArray3.au3>" not "#include<FileListToArray.au3>"

Do you understand you can copy the script from the screen in the forums, so you don't have to re-write it with mistakes...?

Best, Randall

Share this post


Link to post
Share on other sites

Yeah sure I understand.

But with that post and that download you got error's.

In the ZIP file with that post from you, the file is: FileListToArray.au3

And the code that you write is: #include<FileListToArray3.au3>

So?

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Yeah sure I understand.

But with that post and that download you got error's.

In the ZIP file with that post from you, the file is: FileListToArray.au3

And the code that you write is: #include<FileListToArray3.au3>

So?

Hi,

I see!

I uploaded the "FilelistToArray3" to the thread at the link in my signature; sorry if I confused you..

Best, randall

[PS I hope that's the correct one! - if not, send me a pm as I am runing out of Kb for attachments...]

Edited by randallc

Share this post


Link to post
Share on other sites

Aah, thx

I though I was stupid or so :)

I can run it again.

But still the folder Windows is in the list. (see screenshot)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Aah, thx

I though I was stupid or so :)

I can run it again.

But still the folder Windows is in the list. (see screenshot)

Hi,

no your screen shot shows "Windows\system32" folders , not "Windows" folder.

if you want to get rid of all folders with Windows as base directory, you'll need to loop through the array of folders first and delete them

Good point, though, and I may add "no subfolders below excluded folder" as an option later.

Best, randall

Woops, wrong again!

I'll look

Randall

OK ; very sorry again; fixed the RegExp in my UDF; not sure how I ever tested it as accurate.

[in my UDF; line about 69

If $sExclude <> "" Then $sExclude = "(?i)(" & StringReplace(StringReplace(StringReplace($sExclude, ".", "\."), "*", ".*"), "?", ".") & ")" ;change the filters to RegExp filters
]

Thanks for pointing it out

Best, Randall

Edited by randallc

Share this post


Link to post
Share on other sites

Perfect :)

Thankx :)

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
Sign in to follow this  
Followers 0