Jump to content

_filelisttoarray, Including Subdirectories


Recommended Posts

I'm making this way too hard - there has got to be an easier way. I'm looking to do the equivelent of the following shell command:

DIR *.txt /s /b

Do I really have to write recursive loops to first list the directories, then search those for more directories, then search the who list for the files? What I want to end up with is an array containing the files including full paths, from all subdirectories. Like the following, only without having to call a CMD shell and use DIR:

#include <array.au3>
#include <file.au3>

Dim $avFileArray

$sShellCmd = "DIR C:\*.txt /S /B > C:\FileList.txt"
RunWait(@ComSpec & " /c " & $sShellCmd, @TempDir)
_FileReadToArray("C:\FileList.txt", $avFileArray)

_ArrayDisplay($avFileArray, "Array of TXT files")

What's the easy, straight forward solution that is whizzing by way over my head right now...? :)

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

Hi,

I don't think so;

Use a UDF like in the "recursive" link in my signature; multiple choices

Best, Randall

Thanks! That's a great list you have there. :(

Looks like it's as bad as it looked originally for trying to do it without Run() calls to the CMD shell. I'm going to move on with w0uter's technique for now, and come back to try some others later when I have more time. Thanks.

:)

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

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