Jump to content

Recommended Posts

Posted

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)
  • 8 months later...
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
  • 9 years later...
Posted

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?

  • Moderators
Posted

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:

  Reveal hidden contents

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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