Jump to content



Photo

RecFileListToArray - New Version 2 Dec 12


  • Please log in to reply
255 replies to this topic

#41 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,385 posts

Posted 12 June 2011 - 06:46 AM

AZJIO,

You need standard wildcard definitions, so you must use: :huh2:

'*.exe;*.msi;*.scr;*.dll;*.cpl;*.ax'

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items








#42 sleepydvdr

sleepydvdr

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 572 posts

Posted 16 June 2011 - 08:08 PM

Melba23, I just found your UDF and I like it. I like it so much, I want to make it part of my #include folder. However, you didn't offer a calltip, so I wrote one (I don't believe in just asking for everything handed to me, so I researched how to create one and insert it in Scite).

If you want to improve upon it, please do so:

_RecFileListToArray ("Path", "Include List", "Return", Recursion, Sort, Return Path, "Exclude List", "Exclude List Folder") Lists files and\or folders in specified path with optional recursion to defined level and result sorting (required: #include <_RecFileListToArray.au3>

#include <ByteMe.au3>

#43 Fire

Fire

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 362 posts

Posted 17 June 2011 - 09:17 PM

Awesome!)
Thank you!

#44 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 8,869 posts

Posted 17 June 2011 - 09:36 PM

Melba23, I just found your UDF and I like it. I like it so much, I want to make it part of my #include folder. However, you didn't offer a calltip, so I wrote one (I don't believe in just asking for everything handed to me, so I researched how to create one and insert it in Scite).

If you want to improve upon it, please do so:

_RecFileListToArray ("Path", "Include List", "Return", Recursion, Sort, Return Path, "Exclude List", "Exclude List Folder") Lists files and\or folders in specified path with optional recursion to defined level and result sorting (required: #include <_RecFileListToArray.au3>

Often wondered how you make them, but never looked into it.

I thing just one parameter is needed though, so would it be

_RecFileListToArray ("Path", "[Include List]", "[Return]", "[Recursion]", "[Sort]", "[Return Path]", "[Exclude List]", "[Exclude List Folder]") Lists files and\or folders in specified path with optional recursion to defined level and result sorting (required: #include <_RecFileListToArray.au3>

AutoIt Absolute Beginners Require a serial
Run('hh mk:@MSITStore:'&StringReplace(@AutoItExe,'.exe','.chm')&'::/html/tutorials/helloworld/helloworld.htm','',@SW_MAXIMIZE)

#45 MvGulik

MvGulik

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,795 posts

Posted 17 June 2011 - 11:01 PM

Often wondered how you make them, but never looked into it.

API file/line's I presume. ... Preferably automatically. (<funcName>'('<param text>')'[<funcRemark>]<NL>)
Don't Fall in Love With Ideas"If you fall in love with an idea, you won't see the merits of alternative approaches -- and will probably miss an opportunity or two. One of life's great pleasures is letting go of a previously cherished idea. Then you're free to look for new ones. What part of your idea are you in love with? What would happen if you kissed it goodbye?"

#46 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,385 posts

Posted 18 June 2011 - 02:50 PM

JohnOne,

This explains how to add user calltips and autocomplete in SciTE for UDFs. :huh2:

I use this calltip myself:
; _RecFileListToArray($sPath[, $sInclude_List = "*"[, $iReturn = 0[, $fRecur = 0[, $fSort = 0[, $sReturnPath = 1[, $sExclude_List = ""]]]]]]) Lists files and\or folders in a specified path with optional recursion and sort. (Requires: #include <RecFileListToArray.au3>) ;

As to how it is done, there are a number of scripts on the forum which parse the headers of the UDF functions and add them to the correct files automatically. I wrote my own, but it is so tightly bound into my system that it is not a lot of use to anyone else without a lot of modification. ;)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#47 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,385 posts

Posted 30 August 2011 - 01:57 PM

AZJIO,

1. Multiple function call takes longer

Longer than what? :)

2. Mask *.doc will include *.docx

Have you tried? I add the \z end-of-string parameter to the mask SRE to make sure that it does not. :)

M23

Edit: After looking at your code in more detail:

- I see the speed difference between the 2 scripts, but the method you use to match files is not equivalent to that used in the UDF. As I mentioned above, I am using an SRE to look for a match - this enables you to have a far wider range of matches than that allowed by StringInStr. For example you can search for parts of the filename, not just an extension. :)

- Since you seem keen on speed improvements, you might like to note that:

StringInStr(FileGetAttrib($Path & '\' & $file), "D")

is not needed since FileFindNextFile started returning

@extended set to 1 if filename is a directory

in v3.3.2.0 (Dec 2009) - it makes for a real saving in each pass through the loop. :party:

Edit: Editor screwing up text attributes when you try to edit a post! Surprise, surprise! :mellow:

Edited by Melba23, 30 August 2011 - 05:21 PM.

StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#48 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,385 posts

Posted 30 August 2011 - 05:53 PM

AZJIO,

As I have explained at length above, I wrote this UDF to meet my particular needs. As such it does exactly what I want - particularly in the sorting routine. I am well aware that there are faster ways to recursively list files but so far I have not found one which does precisely whatI require- so I wrote my own UDF. I am sure the script you linked to does exactly what you want - but it does not meet my requirements. :)

You also appear not to have looked into the UDF code - nor indeed tried it very much. If you had done so, you would see that I do not run several file searches against the various different elements of $sInclude_List and $sExclude_List - I search once for all files on the path and then use SREs to match them against the masks generated from the Include/Exclude lists. And I am not at all happy that you post incorrect information such as "Mask *.doc will include *.docx" when a simple test shows it does not. :mellow:

In short, if you have specific comments on the UDF that you would like me to look into, please let me know what they are and I will do so - I am more than happy to consider amending the code as long as it still meets my needs. But please refrain from simplistic, non-constructive criticism such as you have been posting - if you want to do it another way, then do so and post your own UDF (as I know you already have here). :)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#49 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,385 posts

Posted 30 August 2011 - 07:30 PM

All,

Please note that I am not talking to myself here - AZJIO has deleted the posts made earlier today to which I was replying. :mellow:

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#50 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,873 posts

Posted 30 August 2011 - 07:41 PM

All,

Please note that I am not talking to myself here - AZJIO has deleted the posts made earlier today to which I was replying. :mellow:

M23

Luckily I'm sure most of us saw the posts that were here before, so you can rest easy that most of us don't think you're overly batty. :)

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#51 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,385 posts

Posted 30 August 2011 - 07:42 PM

BrewManNH,

overly batty

Just lightly touched, eh! :mellow:

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#52 akurakkauaaa

akurakkauaaa

    Seeker

  • Active Members
  • 25 posts

Posted 30 August 2011 - 10:25 PM

my version :mellow:

http://www.autoitscript.com/forum/topic/129712-myfilelisttoarray-allfiles/

#53 AZJIO

AZJIO

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 998 posts

Posted 31 August 2011 - 12:15 AM

And I am not at all happy that you post incorrect information such as "Mask *.doc will include *.docx" when a simple test shows it does not. :mellow:

Removed a post that gave false information. Random coincidence of circumstances, initially could not use the mask. Conclusions made on the basis of AutoIt.chm.

#54 TopXm

TopXm

    Seeker

  • Normal Members
  • 2 posts

Posted 11 October 2011 - 08:35 PM

Hello :graduated:

Sorry for my poor english ...

I want to use _RecFileListToArray() but some problems arise

Plain Text         
#include <RecFileListToArray.au3> #include <array.au3>   Local Const $DirGlob = "C:\Test" Local Const $SubDir1 = "C:\Test\Bob1" Local Const $SubDir2 = "C:\Test\Bob1\plop" Local Const $SubDir3 = "C:\Test\Bob1\plop1" Local Const $FileName = "MyFile.Txt" Local $I, $nFile   ; I create some folders to test UDF For $I = 0 to 15     If Not FileExists($DirGlob & "\Bob" & $I) Then DirCreate($DirGlob & "\Bob" & $I) Next   ;I create subfolders who contain a text file i want to retreive If Not FileExists($SubDir1) Then DirCreate($SubDir1) If Not FileExists($SubDir2) Then DirCreate($SubDir2) If Not FileExists($SubDir3) Then DirCreate($SubDir3)   ;I create the same file in the tree subfolders $nFile = FileOpen($SubDir1 & "\" & $FileName, 2) FileClose($nFile) $nFile = FileOpen($SubDir2 & "\" & $FileName, 2) FileClose($nFile) $nFile = FileOpen($SubDir3 & "\" & $FileName, 2) FileClose($nFile)   ; 1/ MyFile.Txt in Bob1 and subfolders (Recursive + NoOrder + RelativePath) (OK it's good) Local $Array1 = _RecFileListToArray($SubDir1, $FileName, 1, 1, 0, 1)   If IsArray($Array1) Then _ArrayDisplay($Array1, "Array1")   ; 2/ I want to find  MyFile.Txt in C:\Test ; I want to retreive the folder's Name where MyFile.txt exists (Recursive + NoOrder + FullPath) Local $Array2 = _RecFileListToArray($DirGlob, $FileName, 2, 1, 0, 1)   if IsArray($Array2) Then _ArrayDisplay($Array2, "Array2")   ; 3/ I want to find MyFile.Txt in C:\Test  (Recursive + NoOrder + FullPath) ; I retriver all Folders and Files ! Local $Array3 = _RecFileListToArray($DirGlob, $FileName, 0, 1, 0, 1)   if IsArray($Array3) Then _ArrayDisplay($Array3, "Array3")   ; I delete test environment DirRemove($DirGlob, 1)


My questions :
  • For the The third search, why i receive all folders and files when filter is "MyFile.txt" ?
  • If i replace "MyFile.txt" by "*.txt" the results are not the sames ?
  • Last question, if y want to retreive all foldernames of a specific file, how can it be done?
Thank's

#55 DXRW4E

DXRW4E

    Adventurer

  • Active Members
  • PipPip
  • 131 posts

Posted 12 October 2011 - 02:43 AM

Try this http://www.autoitscript.com/forum/topic/131277-filelisttoarrayex/page__p__913945#entry913945

Ciao.

#56 Massi

Massi

    Seeker

  • New Members
  • 2 posts

Posted 12 October 2011 - 10:11 AM

Hi all, my first post. Sorry for my english.
I like this UDF and I will try also the others projects suggested in this topic for sure.
Maybe I've found a bug in this UDF or I misunderstand how to use in the proper way _RecFileListToArray
My purpose is to find the folder where a file is placed (I know the file name). The function works well but I have an error if the name of file to search contains bracket [
Please try to create a file C:\Test\Nuovo Documento di [testo.txt and test the code below. Try again modifing the code and the name of txt with Nuovo Documento di testo.txt (without the bracket). Please let me know if I'm wrong using this function.

#include "RecFileListToArray.au3" Dim $aFile,$FileName,$Test="C:\Test\" $FileName="Nuovo Documento di [testo.txt" $aFile=_RecFileListToArray($Test,$FileName, 1,1,0,1,"","") If @error=1 Then   MsgBox(0,"Error","@Error:"&@error&@CR&"@Extended:"&@extended) Else   MsgBox(0,"OK",$aFile[1]) EndIf

Edited by Massi, 12 October 2011 - 10:17 AM.


#57 AZJIO

AZJIO

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 998 posts

Posted 12 October 2011 - 09:36 PM

Melba23
$sList = StringReplace(StringReplace(StringRegExpReplace($sList, "[][$^.{}()+]", "\\$0"), "?", "."), "*", ".*?")


#58 Spiff59

Spiff59

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,312 posts

Posted 13 October 2011 - 07:52 PM

I'm seeing some other recursive versions of FLTA also aren't handling certain special characters in filenames.
Your SREP mod works for me with the exception that I needed to escape the square brackets: "[\]\[$^.{}()+]"

Edit: Hmm, I didn't stick the brackets at the very front of the list of chars. I now tried your order and it's working without the slashes... odd. working with regular expressions is a great way for me to get confused (even though this is as basic as SRE gets), but it appears that order makes a difference...

Edited by Spiff59, 13 October 2011 - 08:02 PM.


#59 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,385 posts

Posted 13 October 2011 - 08:03 PM

Sorry for the delay in replying - I have been away for a few days on a very interesting course. ;)

TopXm,

For the The third search, why i receive all folders and files when filter is "MyFile.txt" ?

Because that is what the UDF does if you set $iReturn to 0 and $iRecur to something other than 0. Look at the first post and the filter logic:
$iRecur <> 0 and $iReturn = 0 (Files + Folders) Searches and returns all folders unless explicitly excluded
Please remember that (as I explained a few posts above): "I wrote this UDF to meet my particular needs" and that is what I wanted it to do. If you just want the files then set $iReturn to 1 and all you get returned is the files. :D

If i replace "MyFile.txt" by "*.txt" the results are not the sames ?

They are the same for me - can you explain what results you get? ;)

if y want to retreive all foldernames of a specific file, how can it be done?

I would do this:
Local $Array3 = _RecFileListToArray($DirGlob, $FileName, 1, 1, 0, 1) For $i = 1 To $Array3[0]     $Array3[$i] = StringReplace($Array3[$i], "\" & $FileName, "") Next _ArrayDisplay($Array3, "Array3")
which will return the folders containing that file. Is that what you want? :)

Massi,

AZJIO has it right - the UDF needs to escape the [ ] characters. :D

AZJIO,

Your suggested SRE looks pretty good at first glance - I will release a new version this weekend once I have tested it fully. :graduated:

Spiff59,

I do not believe you need to escape the [ ] characters - from the Help file:
To include a closing bracket in a set, use it as the first character of the set. e.g. [][] will match either [ or ]
Similarly, the ^ does not need escaping:
To include a caret (^) in a set, put it after the beginning of the set
AZJIO's SRE works fine for me. :D

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#60 Spiff59

Spiff59

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,312 posts

Posted 13 October 2011 - 08:07 PM


Spiff59,

I do not believe you need to escape the [ ] characters - from the Help file:

To include a closing bracket in a set, use it as the first character of the set. e.g. [][] will match either [ or ]
Similarly, the ^ does not need escaping:
To include a caret (^) in a set, put it after the beginning of the set
AZJIO's SRE works fine for me. ;)

M23

Ah... the help file ...
THAT thing :graduated:

Edit: no sheepish grin or embarassed emoticon? I guees Doh! is the best I can do.
It seems to be finding a file named ""Nuovo Documento di ([{te^sto+]}).txt" now, so the added special chars seems to be working with the modded SREP.

Edited by Spiff59, 13 October 2011 - 08:11 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users