Jump to content

A Filefindnextfile That Parse Subfolders?


ezzetabi
 Share

Recommended Posts

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)
Link to comment
Share on other sites

  • 8 months later...

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
Link to comment
Share on other sites

  • 9 years later...

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?

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...