Jump to content

Copy file to all subdirectories


 Share

Recommended Posts

Is there a way to copy one single file to a folder and have it copy that file to all sub-directories within that folder. I can't get it to work via batch files so I was wondering if it's possible to do this with AutoIt. Any ideas? >_

[center][/center][center]Xonos Development[font=trebuchet ms,helvetica,sans-serif]- Resources -[/font]AutoIT Documentation | Active Directory UDF | Windows Services UDF | Koda GUI Designer[/center]

Link to comment
Share on other sites

  • Developers

Ofcourse its possible: Just do a recursive directory scan and copy the file.

Recursive directory traversing is posted many time so should be easy to find.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Is there a way to copy one single file to a folder and have it copy that file to all sub-directories within that folder. I can't get it to work via batch files so I was wondering if it's possible to do this with AutoIt. Any ideas? :(

In a batch file you would do something with: FOR /F ["options"] %%i IN ('DIR /s /A:D') Do XCOPY %SOURCE_FILE% %%i\

In AutoIt you just need a recursive search function to find all the subfolders and FileCopy() to them.

>_<

Edit: Doh! Jos beat me to it!

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

So I don't understand how to do this. I am trying to get an array of sub-folders within a specific folder however, how do I make FileCopy copy to each folder? This is what I've got so far but I don't know where to start.

So I suppose I have to include this function for recursive searching.

#include <DArray.au3>

Now, how do I call this function into play? I suppose I'd do this.

_FileListToArrayXT

and now, after it creates the array - what do I do? Declare it as a variable like this?

$dirArray = _FileListToArrayXT ?

Also, I don't understand how I'd get FileCopy to work with this and copy to each individually found sub directory

FileCopy("file.js" "$dirArray???", 1)

I've included the FileList array function below. Any ideas? If anyone could point me in the right direction, I'd be so very thankful! I'm not looking for someone to write it for me or anything!

DArray.au3

----------

; #FUNCTION# ===========================================================================================

; Name: _FileListToArrayXT

; Description: Lists files and\or folders in specified path(s) (Similar to using Dir with the /B Switch)

; additional features: multi-path, multi-filter, multi-exclude-filter, path format options, recursive search

; Syntax: _FileListToArrayXT([$sPath = @ScriptDir, [$sFilter = "*", [$iRetItemType, [$bRecursive = False, [$sExclude = "", [$iRetFormat = 1]]]]]])

; Parameter(s): $sPath = optional: Search path(s), semicolon delimited (default: @ScriptDir)

; (Example: "C:\Tmp;D:\Temp")

; $sFilter = optional: Search filter(s), semicolon delimited . Wildcards allowed. (default: "*")

; (Example: "*.exe;*.txt")

; $iRetItemType = Include in search: 0 = Files and Folder, 1 = Files Only, 2 = Folders Only

; $iRetPathType = Returned element format: 0 = file/folder name only, 1 = relative path, 2 = full path

; $bRecursive = optional: True: recursive search including all subdirectories

; False (default): search only in specified folder

; $sExclude = optional: Exclude filter(s), semicolon delimited. Wildcards allowed.

; (Example: "Unins*" will remove all files/folders that begin with "Unins")

; $iRetFormat = optional: return format

; 0 = one-dimensional array, 0-based

; 1 = one-dimensional array, 1-based (default)

; 2 = String ( "|" delimited)

; Requirement(s): AutoIt Version 3.3.1.1 or newer

; Return Value(s): on success: 1-based or 0-based array or string (dependent on $iRetFormat)

; If no path is found, @error and @extended are set to 1, returns empty string

; If no filter is found, @error and @extended are set to 2, returns empty string

; If $iRetFormat is invalid, @error and @extended are set to 3, returns empty string

; If no data is found, @error and @extended are set to 4, returns empty string

; Author(s): Half the AutoIt Community

; ====================================================================================================

Func _FileListToArrayXT($sPath = "C:\Documents and Settings\Alvin Staff\Application Data\Mozilla\Firefox\Profiles", $sFilter = "*", $iRetItemType = 2, $iRetPathType = 2, $bRecursive = False, $sExclude = "", $iRetFormat = 1)

Local $hSearchFile, $sFile, $sFileList, $sWorkPath, $sRetPath, $iRootPathLen, $iPCount, $iFCount, $fDirFlag

;[check and prepare parameters]

;---------------

If $sPath = -1 Or $sPath = Default Then $sPath = @ScriptDir

;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons

$sPath = StringRegExpReplace(StringRegExpReplace($sPath, "(\s*;\s*)+", ";"), "\A;|;\z", "")

;check that at least one path is set

If $sPath = "" Then Return SetError(1, 1, "")

;-----

If $sFilter = -1 Or $sFilter = Default Then $sFilter = "*"

;prepare filter

;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons

$sFilter = StringRegExpReplace(StringRegExpReplace($sFilter, "(\s*;\s*)+", ";"), "\A;|;\z", "")

;check for invalid chars or that at least one filter is set

If StringRegExp($sFilter, "[\\/><:\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")

If $bRecursive Then

;Convert $sFilter for Regular Expression

$sFilter = StringRegExpReplace($sFilter, '([\Q\.+[^]$(){}=!\E])', '\\$1')

$sFilter = StringReplace($sFilter, "?", ".")

$sFilter = StringReplace($sFilter, "*", ".*?")

$sFilter = "(?i)\A(" & StringReplace($sFilter, ";", "$|") & "$)" ;case-insensitive, convert ';' to '|', match from first char, terminate strings

;$sFilter = "(?i)\A" & StringReplace($sFilter, ";", "|") & "\z"

EndIf

;-----

If $iRetItemType <> "1" And $iRetItemType <> "2" Then $iRetItemType = "0"

;-----

If $iRetPathType <> "1" And $iRetPathType <> "2" Then $iRetPathType = "0"

;-----

$bRecursive = ($bRecursive = "1")

;-----

If $sExclude = -1 Or $sExclude = Default Then $sExclude = ""

If $sExclude Then

;prepare $sExclude

;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons

$sExclude = StringRegExpReplace(StringRegExpReplace($sExclude, "(\s*;\s*)+", ";"), "\A;|;\z", "")

;Convert $sExclude for Regular Expression

$sExclude = StringRegExpReplace($sExclude, '([\Q\.+[^]$(){}=!\E])', '\\$1')

$sExclude = StringReplace($sExclude, "?", ".")

$sExclude = StringReplace($sExclude, "*", ".*?")

$sExclude = "(?i)\A(" & StringReplace($sExclude, ";", "$|") & "$)" ;case-insensitive, convert ';' to '|', match from first char, terminate strings

;$sExclude = "(?i)\A" & StringReplace($sExclude, ";", "|") & "\z"

EndIf

;-----

;If $iRetFormat <> "0" And $iRetFormat <> "2" Then $iRetFormat = "1"

If Not ($iRetItemType = 0 Or $iRetItemType = 1 Or $iRetItemType = 2) Then Return SetError(3, 3, "")

;---------------

;[/check and prepare parameters]

;---------------

Local $aPath = StringSplit($sPath, ';', 1) ;paths array

Local $aFilter = StringSplit($sFilter, ';', 1) ;filters array

;---------------

If $bRecursive Then ;different handling for recursion (strategy: unfiltered search for all items and filter unwanted)

If $sExclude Then ;different handling dependent on $sExclude parameter is set or not

For $iPCount = 1 To $aPath[0] ;Path loop

$sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash

If Not FileExists($sPath) Then ContinueLoop

$iRootPathLen = StringLen($sPath) - 1

Local $aPathStack[1024] = [1, $sPath]

While $aPathStack[0] > 0

$sWorkPath = $aPathStack[$aPathStack[0]]

$aPathStack[0] -= 1

;-----

$hSearchFile = FileFindFirstFile($sWorkPath & '*')

If @error Then ContinueLoop

;-----

Switch $iRetPathType

Case 2 ;full path

$sRetPath = $sWorkPath

Case 1 ;relative path

$sRetPath = StringTrimLeft($sWorkPath, $iRootPathLen + 1)

EndSwitch

;-----

Switch $iRetItemType

Case 1

While True ;Files only

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

$fDirFlag = @extended

If $fDirFlag Then

$aPathStack[0] += 1

If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[uBound($aPathStack) * 2]

$aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"

ContinueLoop

EndIf

If StringRegExp($sFile, $sExclude) Then ContinueLoop

If StringRegExp($sFile, $sFilter) Then

$sFileList &= $sRetPath & $sFile & "|"

EndIf

WEnd

Case 2

While True ;Folders only

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

$fDirFlag = @extended

If StringRegExp($sFile, $sExclude) Then ContinueLoop

If $fDirFlag Then

$aPathStack[0] += 1

If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[uBound($aPathStack) * 2]

$aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"

If StringRegExp($sFile, $sFilter) Then

$sFileList &= $sRetPath & $sFile & "|"

EndIf

EndIf

WEnd

Case Else

While True ;Files and Folders

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

$fDirFlag = @extended

If StringRegExp($sFile, $sExclude) Then ContinueLoop

If $fDirFlag Then

$aPathStack[0] += 1

If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[uBound($aPathStack) * 2]

$aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"

EndIf

If StringRegExp($sFile, $sFilter) Then

$sFileList &= $sRetPath & $sFile & "|"

EndIf

WEnd

EndSwitch

;-----

WEnd

FileClose($hSearchFile)

Next ;$iPCount - next path

Else ;If Not $sExclude

For $iPCount = 1 To $aPath[0] ;Path loop

$sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash

If Not FileExists($sPath) Then ContinueLoop

$iRootPathLen = StringLen($sPath) - 1

Local $aPathStack[1024] = [1, $sPath]

While $aPathStack[0] > 0

$sWorkPath = $aPathStack[$aPathStack[0]]

$aPathStack[0] -= 1

;-----

$hSearchFile = FileFindFirstFile($sWorkPath & '*')

If @error Then ContinueLoop

;-----

Switch $iRetPathType

Case 2 ;full path

$sRetPath = $sWorkPath

Case 1 ;relative path

$sRetPath = StringTrimLeft($sWorkPath, $iRootPathLen + 1)

EndSwitch

;-----

Switch $iRetItemType

Case 1

While True ;Files only

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

If @extended Then

$aPathStack[0] += 1

If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[uBound($aPathStack) * 2]

$aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"

ContinueLoop

EndIf

If StringRegExp($sFile, $sFilter) Then

$sFileList &= $sRetPath & $sFile & "|"

EndIf

WEnd

Case 2

While True ;Folders only

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

If @extended Then

$aPathStack[0] += 1

If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[uBound($aPathStack) * 2]

$aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"

If StringRegExp($sFile, $sFilter) Then

$sFileList &= $sRetPath & $sFile & "|"

EndIf

EndIf

WEnd

Case Else

While True ;Files and Folders

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

If @extended Then

$aPathStack[0] += 1

If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[uBound($aPathStack) * 2]

$aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"

EndIf

If StringRegExp($sFile, $sFilter) Then

$sFileList &= $sRetPath & $sFile & "|"

EndIf

WEnd

EndSwitch

;-----

WEnd

FileClose($hSearchFile)

Next ;$iPCount - next path

EndIf ;If $sExclude

Else ;If Not $bRecursive (strategy: filtered search for items)

If $sExclude Then ;different handling dependent on $sExclude parameter is set or not

For $iPCount = 1 To $aPath[0] ;Path loop

$sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash

If Not FileExists($sPath) Then ContinueLoop

;-----

Switch $iRetPathType

Case 2 ;full path

$sRetPath = $sPath

Case 1 ;relative path

$sRetPath = ""

EndSwitch

For $iFCount = 1 To $aFilter[0] ;filter loop

;-----

$hSearchFile = FileFindFirstFile($sPath & $aFilter[$iFCount])

If @error Then ContinueLoop

;-----

Switch $iRetItemType

Case 1 ;files Only

While True

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

If @extended Then ContinueLoop ;bypass folder

;check for exclude files

If StringRegExp($sFile, $sExclude) Then ContinueLoop

$sFileList &= $sRetPath & $sFile & "|"

WEnd

Case 2 ;folders Only

While True

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

If @extended Then ;bypass file

;check for exclude folder

If StringRegExp($sFile, $sExclude) Then ContinueLoop

$sFileList &= $sRetPath & $sFile & "|"

EndIf

WEnd

Case Else ;files and folders

While True

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

;check for exclude files/folder

If StringRegExp($sFile, $sExclude) Then ContinueLoop

$sFileList &= $sRetPath & $sFile & "|"

WEnd

EndSwitch

FileClose($hSearchFile)

Next ;$iFCount - next filter

Next ;$iPCount - next path

Else ;If Not $sExclude

For $iPCount = 1 To $aPath[0] ;Path loop

$sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash

If Not FileExists($sPath) Then ContinueLoop

;-----

Switch $iRetPathType

Case 2 ;full path

$sRetPath = $sPath

Case 1 ;relative path

$sRetPath = ""

EndSwitch

For $iFCount = 1 To $aFilter[0] ;filter loop

;-----

$hSearchFile = FileFindFirstFile($sPath & $aFilter[$iFCount])

If @error Then ContinueLoop

;-----

Switch $iRetItemType

Case 1 ;files Only

While True

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

If @extended Then ContinueLoop ;bypass folder

$sFileList &= $sRetPath & $sFile & "|"

WEnd

Case 2 ;folders Only

While True

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

If @extended Then ;bypass file

$sFileList &= $sRetPath & $sFile & "|"

EndIf

WEnd

Case Else ;files and folders

While True

$sFile = FileFindNextFile($hSearchFile)

If @error Then ExitLoop

$sFileList &= $sRetPath & $sFile & "|"

WEnd

EndSwitch

FileClose($hSearchFile)

Next ;$iFCount - next filter

Next ;$iPCount - next path

EndIf ;If $sExclude

EndIf ;If $bRecursive

;---------------

;set according return value

If $sFileList Then

Switch $iRetFormat

Case 2 ;return a delimited string

Return StringTrimRight($sFileList, 1)

Case 0 ;return a 0-based array

Return StringSplit(StringTrimRight($sFileList, 1), "|", 2)

Case Else ;return a 1-based array

Return StringSplit(StringTrimRight($sFileList, 1), "|", 1)

EndSwitch

Else

Return SetError(4, 4, "")

EndIf

EndFunc ;==>_FileListToArrayXT

Edited by Richardo

[center][/center][center]Xonos Development[font=trebuchet ms,helvetica,sans-serif]- Resources -[/font]AutoIT Documentation | Active Directory UDF | Windows Services UDF | Koda GUI Designer[/center]

Link to comment
Share on other sites

  • Developers

Maybe you can have a play with this script:

$RootDir = "c:\"
$Sourece_File = "C:\File2Copy.txt"
$Dircount = 0
Global $n_Dirnames[1000] ; max number of directories that can be counted
Global $n_DirCount = 0
Global $n_File, $n_Search, $n_tFile
Global $T_DirCount = 1
; remove the end \
If StringRight($RootDir, 1) = "\" Then $RootDir = StringTrimRight($RootDir, 1)
$n_Dirnames[$T_DirCount] = $RootDir
; Exit if base dir doesn't exists
If Not FileExists($RootDir) Then Exit
; keep on looping untill all directories are counted
While $T_DirCount > $n_DirCount
    ; Process next directory in the Array
    $n_DirCount = $n_DirCount + 1
    ;
    ; Copy file to target directory
    FileCopy($Sourece_File,$n_Dirnames[$n_DirCount],1)
    ConsoleWrite('+ File ' & $Sourece_File & '  copied to' & $n_Dirnames[$n_DirCount] & @CRLF)
    ; Find first entry in this directory
    $n_Search = FileFindFirstFile($n_Dirnames[$n_DirCount] & "\*.*")
    If $n_Search = -1 Then
        ContinueLoop
    EndIf
    ; Process all files/directories found
    While 1
        $n_File = FileFindNextFile($n_Search)
        If @error Then ExitLoop
        ; skip these references
        If $n_File = "." Or $n_File = ".." Then
            ContinueLoop
        EndIf
        ; Total Path to file is formed
        $n_tFile = $n_Dirnames[$n_DirCount] & "\" & $n_File
        ; if Directory than add to the list of directories to be processed
        If StringInStr(FileGetAttrib($n_tFile), "D") > 0 Then
            ; Extent Array when needed.
            If UBound($n_Dirnames)-4 < $T_DirCount Then
                ReDim $n_Dirnames[$T_DirCount+1000]
            EndIf
            ; Process Directory entries
            $T_DirCount = $T_DirCount + 1
            $n_Dirnames[$T_DirCount] = $n_tFile
        Else
            ; Process file entries
        EndIf
    WEnd
    FileClose($n_Search)
WEnd
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Awesome! It works... Hmm, a very different approach than what I was trying. I will learn and observe as much as I can from this. Thank you all for your help!

[center][/center][center]Xonos Development[font=trebuchet ms,helvetica,sans-serif]- Resources -[/font]AutoIT Documentation | Active Directory UDF | Windows Services UDF | Koda GUI Designer[/center]

Link to comment
Share on other sites

Or like this

Global $FileToCopy = "C:\MyFile.txt"
_CopyFileToFolders ("D:\PM")

Func _CopyFileToFolders($current)
    
    FileCopy($FileToCopy,$current & "\*")
    
    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop

        If StringInStr(FileGetAttrib($current & "\" & $file), "D") Then _CopyFileToFolders($current & "\" & $file)

    WEnd
    FileClose($search)

EndFunc
Edited by ChrisL
Link to comment
Share on other sites

Is there a way to copy one single file to a folder and have it copy that file to all sub-directories within that folder. I can't get it to work via batch files so I was wondering if it's possible to do this with AutoIt. Any ideas? >_<

TreeFileCopy("C:\sourcedir","C:\destdir\",1 ,"GIF",False)

Func TreeFileCopy($sourcedir ,$destdir,$iFlag = 0 ,$extension = "",$CopyInSingleDir = True)
$TREE_Array = Tree_FileFind($sourcedir,1 ,$extension) ;$iFlag = 1 ==> Return files only / $extension = GIF IMAGE
If StringRight($destdir,1) = "\" Then $destdir = StringTrimRight($destdir,1)
Select
Case $CopyInSingleDir = False
For $I = 1 To $TREE_Array[0] Step 1
$dest = $destdir & StringTrimLeft($TREE_Array[$i],StringLen($sourcedir))
FileCopy ( $TREE_Array[$i], $dest , 1 + 8)
Next
Case $CopyInSingleDir = True
For $I = 1 To $TREE_Array[0] Step 1
$dest = StringSplit($TREE_Array[$i],"\")
$dest = $destdir & "\" & $I & $dest[$dest[0]]
FileCopy ( $TREE_Array[$i], $dest , 1 + 8)
Next
EndSelect
EndFunc

Func Tree_FileFind($szPath = "",$iFlag = 0 ,$extension = "")
Local $TREE_Array[1] ,$FileFind_Array,$Files_Array,$Dirs_Array
$TREE_Array[0] = 0
$szPath = StringReplace($szPath , "\\" , "\" )
If StringRight($szPath,1) = "\" Then _
$szPath = StringTrimRight($szPath,1)
If Not FileExists($szPath) Then Return $TREE_Array
$FileFind_Array = FileFind($szPath ,$TREE_Array,$iFlag,$extension)
IF IsArray($FileFind_Array) Then
$Dirs_Array  = $FileFind_Array[1]
$TREE_Array  = $FileFind_Array[2]

For $I = 1 To $Dirs_Array[0]
Local $CHK_DRIVE = StringSplit($Dirs_Array[$I], "\")
If $CHK_DRIVE[0] < 3 Then
$FileFind_Array2 = FileFind($Dirs_Array[$I] ,$TREE_Array,$iFlag,$extension)
IF IsArray($FileFind_Array2) Then
$Dirs_Array2 = $FileFind_Array2[1]
$TREE_Array  = $FileFind_Array2[2]
For $I2 = 1 To $Dirs_Array2[0]
$TREE_Array = LoopTree_FileFind($Dirs_Array2[$I2],$iFlag,$extension ,$TREE_Array)
Next
EndIf
Else
$TREE_Array = LoopTree_FileFind($Dirs_Array[$I],$iFlag,$extension,$TREE_Array)
EndIf
Next
EndIf
Return $TREE_Array
EndFunc


Func FileFind($szPath , $TREE_Array , $iFlag , $extension)
Dim $FileFind_Array[4]
$FileFind_Array[0] = 2
Dim $Dirs_Array[1]
$Dirs_Array[0] = 0
FileChangeDir($szPath)
Local $sFilter = "*.*"
if $iFlag = 2 Then $sFilter = "*."
Local $search = FileFindFirstFile($sFilter)
If $search = -1 Then Return -1
While 1
    Local $file = FileFindNextFile($search)
    If @error Then ExitLoop

    Select
    Case StringInStr(FileGetAttrib($file), "D") = True
    IF $iFlag <> 1 Then
    ReDim $TREE_Array[$TREE_Array[0] + 2]
    $TREE_Array[$TREE_Array[0] + 1] = $szPath & "\" & $file
    $TREE_Array[0] = $TREE_Array[0] + 1
    EndIf
    If StringInStr(FileGetAttrib($file), "S") = True Then _
    ContinueLoop
    ReDim $Dirs_Array[$Dirs_Array[0] + 2]
    $Dirs_Array[$Dirs_Array[0] + 1] = $szPath & "\" & $file
    $Dirs_Array[0] = $Dirs_Array[0] + 1




    Case StringInStr(FileGetAttrib($file), "D") = False
    if $iFlag = 2 Then ContinueLoop
    Select
    Case StringLen(StringStripWS($extension, 8)) <> 0
    If Not (StringUpper(StringRight($file,StringLen($extension))) = StringUpper($extension)) _
    Then ContinueLoop
    ReDim $TREE_Array[$TREE_Array[0] + 2]
    $TREE_Array[$TREE_Array[0] + 1] = $szPath & "\" & $file
    $TREE_Array[0] = $TREE_Array[0] + 1
    Case StringLen(StringStripWS($extension, 8)) = 0
    ReDim $TREE_Array[$TREE_Array[0] + 2]
    $TREE_Array[$TREE_Array[0] + 1] = $szPath & "\" & $file
    $TREE_Array[0] = $TREE_Array[0] + 1
    EndSelect

    EndSelect
WEnd
FileClose($search)
FileChangeDir(@SCriptDir)
$FileFind_Array[1] = $Dirs_Array
$FileFind_Array[2] = $TREE_Array
Return $FileFind_Array
EndFunc



Func LoopTree_FileFind($szPath , $iFlag , $extension , $TREE_Array)
Local $FileFind_Array,$Files_Array,$Dirs_Array
$FileFind_Array = FileFind($szPath,$TREE_Array,$iFlag,$extension)
IF IsArray($FileFind_Array) Then
$Dirs_Array = $FileFind_Array[1]
$TREE_Array = $FileFind_Array[2]
For $I = 1 To $Dirs_Array[0]
$TREE_Array = LoopTree_FileFind($Dirs_Array[$I],$iFlag,$extension,$TREE_Array)
Next
EndIf
Return $TREE_Array
EndFunc
Edited by wolf9228

صرح السماء كان هنا

 

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