Listing Files Within a Folder

Monte Goulding monte.goulding at senet.com.au
Wed Dec 18 18:27:01 EST 2002


You will need either a repeat loop or recursion

I'd go for the repeat loop. There's a neat way to use a queue for tree
traversal as in the following pseudocode:

put the directories of the root folder into a queue (probably a multi-line
variable)
put the files of the root folder into tFiles
repeat until the queue is empty
  put the head of the queue into tPath
  put the directories of folder tPath after the tail of the queue
  put the files of the root folder after tFiles
end repeat

Theis algorithmn will result in level-order traversal. So if you have a
tree:
       1
      / \
     2   5
    / \  /\
   3  4 6  7

You will get the files in the order 1,2,5,3,4,6,7

If you want to get the files by in-order traversal (1,2,3,4,5,6,7) then you
need to use a stack and push the sub-directories of a folder on after you
pop the folder. Still repeating until the stack is empty.

Cheers

Monte

> -----Original Message-----
> From: metacard-admin at lists.runrev.com
> [mailto:metacard-admin at lists.runrev.com]On Behalf Of Gregory Lypny
> Sent: Thursday, 19 December 2002 9:11 AM
> To: metacard at lists.runrev.com
> Subject: Listing Files Within a Folder
>
>
> Hello everyone,
>
> 	What's the best way of getting a list of files that reside
> in a number
> of subfolders within a parent folder?  What I've done is establish the
> path to the parent folder.  I then use  the Directories command to get
> a list of subfolders, and by setting the directory property to each
> subfolder in a repeat loop, I obtain files lists using the Files.
>
> 	Greg
>
>
>
>
>
> Gregory Lypny
> Concordia University
> ___________________
> "Better for us if you don't understand."
> 	The Tragically Hip
>
> http://rubbersoul.concordia.ca
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard




More information about the metacard mailing list