Sign in to follow this  
Followers 0
jguinch

Strange behaviour with _FileListToArrayRec

5 posts in this topic

#1 ·  Posted (edited)

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.

Edited by jguinch

Share this post


Link to post
Share on other sites



You know, we have a bug tracker for these types of issues?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

jguinch,

This has been discussed before and is the result of _FileListToArray passing the filter directly to Windows to search for the files while _FileListToArrayRec looks through all files and uses a RegEx to extract those that match the filter. Hence the discrepancy when the filter for the latter function holds a "." - the Regex will only match a name which includes a "." while Windows is far less fussy. :)

As explained in the linked thread, we see this as a Windows "feature/bug" rather then an AutoIt problem - and we certainly have no intention of changing the behaviour of either function. I added some remarks to the Help file explaining the difference between the 2 functions - did you read them? ;)

I will be closing the bug report - please use this thread if you wish to discuss it further. :)

M23

Edit: 22k

Edited by Melba23
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Similar Content

    • TryWare90Days
      By TryWare90Days
      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.
       
       
    • drorshem
      By drorshem
      Hi,
      I'm looking to create a script which will download all *.txt files from a remote FTP server.
      Once downloaded, delete all *.txt files.
       
      Can this be achieved using AutoIt ?
    • 232showtime
      By 232showtime
      is there a limitation for _FileListToArrayRec? I tried to a do _FileListToArrayRec in C: Directory and it takes forever for _ArrayDisplay
    • RaiNote
      By RaiNote
      Hi,
      How to create Wildcards to search for a Filename and also for a String within a File and within the own script.
    • prazetto
      By prazetto
      WildcardMatch an Fast Filename Pattern Match (UDF)
      Machine Code Version (x32 and x64)
      Repeat the word from an C/C++ Writer {

      Introduction

      Simple wild card matching with ? and * is something that we use in our every day work
      just when opening a command prompt and using DIR and DEL.
      But how can this be done correctly in your program?
      OK, you can use regular expressions, and I recommend this when you already use a
      bunch of Boost, tr1 or STL stuff in your code. But sometimes, I like it easy and simple
      without tons of library code in the background. And because I saw a lot of wrong and
      in complex queries "wrong/failing" code, I just offer this small algorithm here.

      Background

      This wildcard matching function works just the same way as you expect and know it from
      the CMD.EXE DIR command.

      Using the Code
      The function just takes the string to check as a first argument and the mask with or without
      any wildcard characters as a second argument. It returns true if the strings match and false
      if not. It isn't spectacular.

      The characters ? and * are treated as wildcards.
      A ? character matches exactly one character and doesn't match an empty string.
      A * character matches any sequence of characters and an empty string too.
      Other characters are compared caseless. I use CharUpper and convert them to uppercase
      to perform this task. Feel free to use your own favorite way.
      Because * matches any character sequence and an empty string WildcardMatch(_T(""),_T("*"))
      returns true.

      } by Martin Richter, 28 Apr 2011 on codeproject.com

      AutoIt3 WildcardMatch

      No, I'm not doing any translation the C/C++ WildcardMatch to our favorite scripting
      language: AutoIt V3. Instead modificate thats source to be:

      - Ansi and Wide text version of WildcardMatch.
      - Portable and meet the condition to be used on
        Shell Code or Machine Code (That what Ward, trancexx and other called it!).

      And then write an UDF.
       
      UDF Name : CoreFx.Wildcard.au3 Functions : CoreFx_WildcardMatchExA($string, $patern) CoreFx_WildcardMatchExW($string, $patern) Includes : CoreFx.DynamicCode.au3 General.Imports.au3 WinAPI.Kernel32.au3 Platform : x32 and x64 bit Sample : $test.au3 .
      Download In Single ZIP (File Size: 5 KB. All required file are included).
      CoreFx.Wildcard.zip

      Sample

      $test.au3 Outputs:
      Ansi Test Empty string 1 CoreFx_WildcardMatchExA("", "*") Return 1 Empty string 2 CoreFx_WildcardMatchExA("", "") Return 1 Simple 1 CoreFx_WildcardMatchExA("MyName.doc", "*.DOC") Return 1 Simple 2 CoreFx_WildcardMatchExA("MyName.docx", "*.DOC") Return 0 Complex 1 CoreFx_WildcardMatchExA("MyNamName.docx", "My*Name.*x") Return 1 Complex 2 CoreFx_WildcardMatchExA("MyNamName.docx", "My*Name.*oc") Return 0 A CoreFx_WildcardMatchExA("filename.txt", "*.txt") Return 1 B CoreFx_WildcardMatchExA("filename.txt", "*.tx?") Return 1 C CoreFx_WildcardMatchExA("filename.txt", "file*name.txt") Return 1 D CoreFx_WildcardMatchExA("filename.txt", "fil*ame.txt") Return 1 E CoreFx_WildcardMatchExA("filename.txt", "f*l*a*e.*x?") Return 1 Wide Test Empty string 1 CoreFx_WildcardMatchExW("", "*") Return 1 Empty string 2 CoreFx_WildcardMatchExW("", "") Return 1 Simple 1 CoreFx_WildcardMatchExW("MyName.doc", "*.DOC") Return 1 Simple 2 CoreFx_WildcardMatchExW("MyName.docx", "*.DOC") Return 0 Complex 1 CoreFx_WildcardMatchExW("MyNamName.docx", "My*Name.*x") Return 1 Complex 2 CoreFx_WildcardMatchExW("MyNamName.docx", "My*Name.*oc") Return 0 A CoreFx_WildcardMatchExW("filename.txt", "*.txt") Return 1 B CoreFx_WildcardMatchExW("filename.txt", "*.tx?") Return 1 C CoreFx_WildcardMatchExW("filename.txt", "file*name.txt") Return 1 D CoreFx_WildcardMatchExW("filename.txt", "fil*ame.txt") Return 1 E CoreFx_WildcardMatchExW("filename.txt", "f*l*a*e.*x?") Return 1 .
      Source
      A Simple Wildcard Matching Function (Martin Richter [MVP C++])

      Wikipedia

      Wildcard Character
      .
      For modified version of WildcardMatch (C++ source). If you need it, just pm me!