Jump to content
Sign in to follow this  
Vlasssov

Search file include sub-directories

Recommended Posts

Vlasssov

Standart functions FileFindFirstFile and FileFindNextFile find file in current directories.

As I can find a file including subdirectories?

If there is a standard example where I can look it?

Share this post


Link to post
Share on other sites
Vlasssov

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.

Share this post


Link to post
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
Sign in to follow this  

×