New topic: 

How to loop through all items in a folder

<http://forums.realsoftware.com/viewtopic.php?t=30661>

       Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic         Author  
Message       rlinsurf           Post subject: How to loop through all items in 
a folderPosted: Mon Oct 26, 2009 12:39 am                        
Joined: Tue Mar 21, 2006 12:49 am
Posts: 40              I now have the following GetFolderItem:

Code:f=GetFolderItem("/Users/jeffrey/Downloads/html/247.txt",_
  FolderItem.PathTypeShell) //"247.txt" is one of maybe 250 files currently in 
the folder
If f.exists then
  stream=f.OpenAsTextFile
  s=stream.ReadAll()


The problem is, there can be many, or just a few, pages in that folder, each of 
which need to be processed, and who's names I don't know.

Is there any way to just loop through the whole folder, and get each item in 
it, no matter what it's name?   
                            Top               timhare           Post subject: 
Re: How to loop through all items in a folderPosted: Mon Oct 26, 2009 1:39 am   
                     
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 6617
Location: Portland, OR  USA              Get a FolderItem to the folder - 
"/Users/jeffrey/Downloads/html" - and then iterate through the FolderItems 
Item() method using the Count property.
Code:f = GetFolderItem("/Users/jeffrey/Downloads/html")
for i = 1 to f.Count
  f2 = f.Item(i)
  if right(f2.name, 4) = ".txt" then
  // do something
  end
next

   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to