Getting Directory Tree

Gordon Tillman got at
Wed Feb 2 14:23:27 EST 2005

Hi Derek,

> I'm at a loss.  I've spent the last 3 hours trying to make a script 
> that will look at 1 directory and provide a complete hierarchial list 
> of all files within all folders and subfolders, and I can't make it 
> work.
> Has anyone else attempted this, and been successful?

How about something like this?

function GetFolderContents pFolder
     local tSaveDefaultFolder, tFolder, tFolders, tList
     put the defaultFolder into tSaveDefaultFolder
     set the defaultFolder to pFolder
     get the folders
     filter it without "."
     filter it without ".."
     put it into tFolders
     local tFiles, tFile
     get the files
     put it into tFiles
     put pFolder & return after tList
     repeat for each line tFile in tFiles
         put pFolder & "/" & tFile & return after tList
     end repeat
     repeat for each line tFolder in tFolders
         put GetFolderContents(tFolder) after tList
     end repeat
     set the defaultFolder to tSaveDefaultFolder
     return tList
end GetFolderContents


More information about the Use-livecode mailing list