Spiff59 Posted April 6, 2012 Posted April 6, 2012 (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 April 6, 2012 by Spiff59
DXRW4E Posted April 6, 2012 Author Posted April 6, 2012 ????? concrete example of what has not worked for you?
Spiff59 Posted April 6, 2012 Posted April 6, 2012 The following returns 0 hits: $b1 = _FileListToArrayEx(@WindowsDir, "s*.???.*", 4)
DXRW4E Posted April 7, 2012 Author Posted April 7, 2012 (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 modhttp://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 validneed 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 April 7, 2012 by DXRW4E
BrewManNH Posted April 7, 2012 Posted April 7, 2012 From Wikipedia about wildcards in filenamesFiles and directoriesWhen 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 GudeHow 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
DXRW4E Posted April 7, 2012 Author Posted April 7, 2012 (edited) Hi BrewManNH, thanks for the info, Unfortunately StringRegExp does not interpret correctly "???" Ciao. Edited April 7, 2012 by DXRW4E
Tlem Posted April 11, 2012 Posted April 11, 2012 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
DXRW4E Posted April 12, 2012 Author Posted April 12, 2012 (edited) Hi Tlem, Thank You for all suggestionsI 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 BITANDThanks Againand sorry again for my EnglishCiao. Edited April 12, 2012 by DXRW4E
Tlem Posted April 12, 2012 Posted April 12, 2012 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
DXRW4E Posted October 9, 2012 Author Posted October 9, 2012 Updated, Added $sFilter Case-sensitivity flag & Disable the return the count in the first element, for more see the first post Ciao.
DXRW4E Posted October 20, 2012 Author Posted October 20, 2012 (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 October 20, 2012 by DXRW4E
Drakken Posted January 23, 2013 Posted January 23, 2013 (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 January 23, 2013 by Drakken
DXRW4E Posted January 23, 2013 Author Posted January 23, 2013 Hi Drakken, Error = 1 - Path not found If Not FileExists($sPath) Then Return SetError(1, 1, "") Are you sure that the path exists? Ciao.
Drakken Posted January 23, 2013 Posted January 23, 2013 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.
guinness Posted January 23, 2013 Posted January 23, 2013 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
Drakken Posted January 23, 2013 Posted January 23, 2013 It's just a mistake. I take another example: _FileListToArrayEx("ls-sifich10Consulting-TechniqueEnseignes",*.*,2) Same error.
DXRW4E Posted January 23, 2013 Author Posted January 23, 2013 (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 January 23, 2013 by DXRW4E
DXRW4E Posted January 23, 2013 Author Posted January 23, 2013 (edited) first post already updated, now will have to be ok? Edited January 23, 2013 by DXRW4E
Neutro Posted January 25, 2013 Posted January 25, 2013 Thank you very much for this function, it's fast and so easy to use! Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now