Jump to content

Recursive FindFirstFile and FindNextFile


Recommended Posts

Is there an easy way to have FindFirstFile search a tree recursively? I've been using the following code (NOT verbatim from my script) and then reading the file and performing actions on the files.

RunWait( @ComSpec & " /c dir/a/s/b files.ext >> C:\temp.txt" )

Is there an easier way? Perhaps a change to the FindFirstFile could be made, such as FindFirstFile( "path", "filenames.ext", recursive ).

$file = FindFirstFile( @MyDocumentsDir, "*.doc;*.xls", 1 )

I'd like to see a function like FindAllFiles( "path", "filenames.ext" [, recursive] [, options] )

Options would be filters for date/time and attributes.

i.e. To find Excel and Word documents under My Documents that have changed:

$myarray = FindAllFiles( @MyDocumentsDir, "*.doc;*.xls", 1, option for Archive attribute )

My real-world example B) is that I have business database software that has an automated backup, but the only way it works is to dump into folders DB1 and DB2, under which are Mon, Tue, Wed, Thu, Fri. I need to move these files from that location to another server and in folders by date (i.e. \\destination\share\20040121\DB1 and DB2). I currently do a "dir /s/b \\source\share\files\*.* > temp.txt" (which gives me files under ...files\DB1\Mon as well as ...files\DB2\Wed) then read temp.txt into an array, look at the date of each file, create a folder in the destination (the \20040121\DB1 part), then move the file. :whistle:

I'm looking for the easiest way to get the list recursively from \\source\share\files\all folders\*.* into an array to work with.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...