Jump to content

Recommended Posts

Posted (edited)

There are so many versions of recursive FileListToarray() functions floating around that I finally decided to pull one out of your huge thread from 2009 and post it all alone so someone could find it without first reading 15 pages of discussion. I just did that, the version contains a great deal of your (and many others) contributions, I hope you don't mind I labeled the authorship as: "Half of the Autoit community".

This version doesn't handle complex wildcards correctly. Try the parameters used in the example in the Recursive _FileListToArray() thread I just started, they don't work here. Edited by Spiff59
Posted (edited)

What are the "???" ? (What do you look for them?, It does not need to use "???"), windows uses them only in case of research in desktopsearch, but defualt ignores them (because those do not serve?), so we too we do not have enabled the search for the "?", the "?" is interpreted in regex mod

http://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm

"?" = The previous character, set or group may or may not appear. Equivalent to {0, 1}

"*" = Repeat the previous character, set or group 0 or more times. Equivalent to {0,}

not there ever a file name with the name "name?name.xxx" ?, so your $sFilter is not valid

need to use these for example

"s*.?.*" = "sname.name.txt" Or "snamename.txt"

"s*.*.*" = "sname.name.txt" (NOT "snamename.txt")

everything seems OK, everything perfect ?

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Posted

From Wikipedia about wildcards in filenames

Files and directories

When specifying file names (or paths) in CP/M, DOS, Microsoft Windows and Unix-like operating systems, the asterisk character ("*") substitutes for any zero or more characters, and the question mark ("?") substitutes for any one character or less but not more than the amount of question marks. For example 123??? will match 1231 or 12313 but not 1239919991.

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

Posted (edited)

Hi BrewManNH, thanks for the info, Unfortunately StringRegExp does not interpret correctly "???"

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Posted

Hi DXRW4E, Thank You for your work.

I understand your point of view about the number of flag, but if you want to keep the AutoIt philosophy, the recurse parameter should be a specific flag (like DirRemove, FileSetAttrib, FileSetTime or other). And so, the path return should be an other parameter.

Like I said and after reflexion, the default return should be path relative and this parameter might be omitted because full path can be obtained by adding $sPath in front of the result. ^^

So, if you are agree, the function should be :

_FileListToArrayEx($sPath[, $sFilter = "*"[, $iFlag = 0 [, $recurse = 0 ]]])

Moreover, I find that the _FileListToArrayEx name should be reserved for more complex functions. But I am in no way persuaded by the will to update the "official" function. ^^

Best Regards.Thierry

Posted (edited)

Hi Tlem, Thank You for all suggestions

I understand you very well, that was just my personal opinion, I really like the BITAND, using the BITAND can add it to function even more 10 flags, without changing the structure of the function ect ect, to give an example such as FileOpen, to me personally it looks much more professional the use of BITAND

Thanks Again

and sorry again for my English

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Posted

Whell, make like you want !

Now it will be more interesting to resolve what Spiff59 said about the mask of search.

It work on _FileListToArray (and probably to Spiff59 function), so in this time, his function is more universal and complete than your's.

You should stop to said "sorry for my English". We know that you'r not English.

I'm not English too and my translation is very often rough. The main part, it is to be understood. ;)

Best Regards.Thierry

  • 5 months later...
  • 2 weeks later...
Posted (edited)

Updated, add $iFlag = 128 Return Backslash at the beginning of the file name, example Return "Filename1.xxx" and the $iFlag = 64 now you can use the $sFilter in RegExp Mod (See Pattern Parameters in StringRegExp )

The following returns 0 hits:

$b1 = _FileListToArrayEx(@WindowsDir, "s*.???.*", 4)

use $iFlag 64 and $sFilter = "[123]+.txt" to find files 1231.txt or 12313.txt 1111111.txt ect ect ("[123]+" = "123???"), see StringRegExp the options are endless them

For example

#include <Array.au3>
#include <_FileListToArrayEx.au3>

Global $a1, $b1
$a1 = TimerInit()
$b1 = _FileListToArrayEx(@WindowsDir, "[123]+.txt", 64)
$a1 = TimerDiff($a1)
_ArrayDisplay($b1, $a1)

now or attached _FileListToArrayEx.au3, because only now noticed that there were parts of the code, the autoit codetag (in the first post of the topic) removed the "=" from the pattern of the regexp ect ect

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

  • 3 months later...
Posted (edited)

Hi.

First, thank you for your script.

I have a little question about its operation.

Is it normal that I get always an error = 1 when my path is a network path?

Example: _FileListToArrayEx (" Servtemp", "*", 2)

Bye.

Edited by Drakken
Posted

Yes the path exists.

I get this error only with network paths.

When I run the original function (_FileListToArray) on the same path I have no errors.

Posted

Drakken,

Is that a space I see between and Serv?

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Posted (edited)

Yes the path exists.

I get this error only with network paths.

When I run the original function (_FileListToArray) on the same path I have no errors.

No normal ???

Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
Local $hSearch, $sFile, $sFileList, $sDelim = "|"
$sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash
If Not FileExists($sPath) Then Return SetError(1, 1, "")
ect ect ect

Func _FileListToArrayEx($sPath, $sFilter = "*", $iFlag = 0)
$sPath = StringRegExpReplace($sPath & "\", "[\\/]+", "\\")
If Not FileExists($sPath) Then Return SetError(1, 1, "")
ect ect ect

maybe that's the problem ("[/]+"), here I see now, hmmmm I forgot the network paths

thanks for reporting

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

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