Recursion and getting folder's complete contents

David Vaughan drvaughan55 at mac.com
Tue May 7 06:22:01 EDT 2002


DB

This question is a favourite with a variety of responses if you look in 
the archives. Here is an example:
-- This recursive function expects a folder path.
-- It returns a file list for that folder and for each
--  sub-folder it contains (pre-order search)
-- Invisible files are excluded.
function walkDir dirPath
   put empty into tList
   set defaultFolder to dirPath
   put the long files into fList
   repeat for each line fLine in fList
     if char 1 of fLine <> "." then
       put item 1 of fLine & comma & last item of fLine into fData
       put dirPath & "/" & fData & return after tList
     end if
   end repeat
   get the folders
   repeat for each line x in it
     if char 1 of x <> "." then
       put walkDir(dirPath & "/" & x) after tList
     end if
   end repeat
   return tList
end walkDir

regards
David

On Tuesday, May 7, 2002, at 07:56 , DropBox ForSpam wrote:

> Hi all!
>
> I've never been able to get a handle on recursion,
> does anyone have a script to get the complete contents
> of a folder?
>
> What I want is to be able to select a folder through
> the answer dialog, and then get a list of every file
> (with it's path) no matter how many folders deep they
> are within that selected folder.   Can anyone help?
>
> DB
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list