Sign in to follow this  
Followers 0
ezzetabi

A Filefindnextfile That Parse Subfolders?

6 posts in this topic

Ok, this is not well formatted UFD, but more a scrap of code that I'll use in mine shell extension. But since I think that can be useful I post it here.

$Path = "C:\Scripts"  ;<---- The path where all begins...

dim $folders[2]
$Files = ""
$dirs = ""
$result = ""

If StringInStr(FileGetAttrib($path),"d") Then
   $folders[0] = 1
   $folders[1] = $Path
   While 1
     For $c = 1 to $folders[0]
         If StringRight($folders[$c],1) == "\" Then $Folders[$c] = StringLeft($folders[$c],StringLen($folders[$c])-1)
         $search = FileFindFirstFile($folders[$c] & "\*.*")
         If $search <> -1 Then
            While 1
               $result = FileFindNextFile($search)
               If @error Then ExitLoop
               If $result <> "." AND $result <> ".." Then
                  $result = $folders[$c] & "\" & $result
                  If StringInStr(FileGetAttrib($result),"d") Then
                     $dirs = $dirs & "|" & $result
                     $files = $files & "|" & $result  ; << --- Remove this line if you do not want the folders names in the final list...
                                                       ;or use an other var if you want divide.
                  Else
                     $files = $files & "|" & $result
                  EndIf
               EndIf   
            WEnd
            FileClose($search)
         EndIf
     Next
     If $dirs = "" Then ExitLoop
     $folders = 0
     $dirs = StringRight($dirs,StringLen($dirs) - 1)
     $folders = StringSplit($dirs,"|")
     $dirs = ""
   WEnd
Else
  ;You decide what to do if $path is not a folder
EndIf
$files = StringRight($files,StringLen($files) - 1)

$files = StringReplace($files,"|",@crlf)
FileWrite("c:\list.txt",$files)

Share this post


Link to post
Share on other sites



Thank you! It is good!

Share this post


Link to post
Share on other sites

I don't understand what the difference is between Larry's version and yours.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I do not even remember I made this script... Who recalled this old topic?

Edit: btw.. I made few testes and it seems actualy faster than both mine _FileSearch and Larry's one. Really interesting...

Edit2: I compared different folder. It is actually fast as other two.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

I didn't try to understand the above script completly now but am I wrong if I suspect that you need a recursive script to include all subfolders in the search and that this script only read the first subfolders found in the main folder?

Share this post


Link to post
Share on other sites

Tekkion,

Did you notice the date in the post above yours? do you really expect a replay after 9 years? :huh:

In future please engage your brain before hitting the "Submit" button. ;)

M23

P.S. And look at _FileListToArrayRec in the Help file - unsuprisingly there is now a standard include function to search within folder trees. ;)


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
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0