Sign in to follow this  
Followers 0
MRXTO09

how find subfiles on subfolder

4 posts in this topic

#1 ·  Posted (edited)

i need to find a subfiles and get the name of the file and the name of the subfolder if the file exists and put alll this line in array.

i've try this

Func __CheckUpload()
$aFolderList = _FileListToArray($dir,"*",2)
for $i=1 to UBound($aFolderList)-1
   $hFiles = _FileListToArray($dir&"\"&$aFolderList[$i],'*.txt',1)
   If Not $hFiles[1] = "" Then 
      Global $folder = $aFolderList[$i]
      __upload()
      Global $folder = ""
   EndIf
Next
EndFunc 

This Is possibile?

Edited by MRXTO09

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

 

did you look at this?

_FileListToArray()
If Not $hFiles[1] = "" Then 
      Global $folder = $aFolderList[$i]
      __upload()
      Global $folder = ""
   EndIf

this don't work

Edited by MRXTO09

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

first, don't declare/re-declare Global variables inside a function. use Global only to create the variable for the first time, not when using it.

second, if no files found then _FileListToArray() will not return an array, so the syntax $hFiles[1] is invalid. check @error after every call to _FileListToArray() to detect this.

Not is an operand, it is subject to mathematical rules. you need to add parenthesis to use it, because this:

not a = b

is the same as:

( not a ) = b

and is not the same as

not ( a = b )

which is what you need. but as you will see now, the @error check makes the Not check unnecessary:

Func __CheckUpload()
    $aFolderList = _FileListToArray($dir,"*",2)
    If @error Then
        MsgBox(16,'Error:','error reading folders list or no folders fonud.')
    Else
        for $i=1 to UBound($aFolderList)-1
            $hFiles = _FileListToArray($dir&"\"&$aFolderList[$i],'*.txt',1)
            If @error Then
                MsgBox(48,'Alert:','no .txt files fonud in folder:'&@CR&$aFolderList[$i])
            Else
                $folder = $aFolderList[$i]
                __upload()
                $folder = ""
            EndIf
       Next
   EndIf
EndFunc
Edited by orbs

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  
Followers 0