Get a List of Files

Scott Rossi scott at tactilemedia.com
Tue Aug 27 17:22:00 EDT 2002


Recently, "Scott Rossi"  wrote:

> How might one get a list of all files from a folder which contains nested
> folders and files several levels deep?

In my ignorance, I forgot to check my archived mail files which contained
this modified code snippet from Geoff Canyon:


global gHierList,gMainFolder,gBaseLevels
local tCount

on mouseUp
  put "" into gHierList
  put "" into fld tresult
  answer folder "Pick a folder you want to walk:"
  put it into gMainFolder
  if gMainFolder = "" then exit mouseUp
  set the itemDel to "/"
  put 0 into tCount
  put the number of items of gMainFolder into gBaseLevels
  directoryWalk gMainFolder
  put gHierList into fld tresult
end mouseUp

on directoryWalk whatFolder
  --put whatFolder
  --exit to top
  set the itemDel to "/"
  set the directory to whatFolder
  put the files into temp
  add the number of lines of temp to tCount
  # filter temp with "*.html"
  sort temp
  repeat for each line x in temp
    put whatFolder & "/" & x & cr after gHierList
  end repeat
  put the folders into tDirList
  sort tDirList
  delete line 1 of tDirList
  repeat for each line x in tDirList
    directoryWalk (whatFolder & "/" & x)
  end repeat
end directoryWalk


Thanks to Ken Ray as well for posting his modified modified version. :-)

(I'll probably make some modifications as well...)

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the metacard mailing list