Jump to content

Search file include sub-directories


 Share

Recommended Posts

Heres one I did, there are lots of examples though.

http://www.autoitscript.com/forum/index.php?showtopic=104982

I have written function

#Include   <File.au3>
#include  <Array.au3>


Func _FindFilesName($sRoot, $sFile,byref $sp)
dim $ss
dim $i

if StringRight($sRoot,1) = "\" Then
$sRoot = StringLeft($sRoot,StringLen($sRoot)-1)

EndIf
$ss = ""
_FindFiles($sRoot, $sFile,$ss)
$sp1 = StringSplit($ss, @TAB)

if  $sp1[0]>0 then
    redim  $sp[$sp1[0]-1]
    for $i=1 to $sp1[0]-2
        $sp[$i] = $sp1[$i+1]
    Next
    $sp[0] = $sp1[0]-2
Else
    $sp[0] = 0
EndIf

EndFunc

Func _FindFiles($sRoot, $sFile, byref $ss)

    Local $FileList
       
    $FileList = _FileListToArray($sRoot, $sFile, 1)
    If Not @error Then
        For $i = 1 To $FileList[0]
 
            $ss = $ss &$sRoot & '\' & $FileList[$i]& @TAB
        Next
     EndIf
    $FileList = _FileListToArray($sRoot, '*', 2)
    If Not @error Then
        For $i = 1 To $FileList[0]
            _FindFiles($sRoot & '\' & $FileList[$i], $sFile,$ss)
        Next
    Else
   
    EndIf
EndFunc

Look, whether it is possible to simplify it.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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