Jump to content

Getting files from folders


Marlo
 Share

Recommended Posts

Hello again! i have run into yet another snag.

You see my script needs to search a folder and its subfolders for all files and i have been using the following code:

Func _SearchFolder($folder)
    $files = _FileListToArray($folder,"*",1)
    $folders = _FileListToArray($folder,"*",2)
    _FileFunc($files,$folder)
    _FolderFunc($folders,$folder)
EndFunc

Func _FileFunc($files,$folder)
    For $i = 1 To UBound($files)-1
        DO STUFF
    Next
EndFunc

Func _FolderFunc($folders,$parentdir)
    For $i = 1 To UBound($folders)-1
        _SearchFolder($parentdir & "\" & $folders[$i])
    Next   
EndFunc

But i dont want it to have to call and recall the _Searchfolder function as it fudges up some stuff that i have in mind.

So is there any way i can either compress my current code into one function or just rewrite a better way of doing it?

Help is greatly apreciated.

ciao

Click here for the best AutoIt help possible.Currently Working on: Autoit RAT
Link to comment
Share on other sites

You could do something like this:

#Include <File.au3>

_SearchFolder("R:\")

Func _SearchFolder($folder)
    $files = _FileListToArray($folder,"*")
    For $X = 1 To $files[0]
        If StringInStr(FileGetAttrib($folder & $files[$X]), "D") Then
        ;Do something when it is a folder, perhaps calling _SearchFolder() again?;)
        Else
        ;Do something else when it is a file
        EndIf
    Next
EndFunc
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...