Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


pruning a Files collection

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61359
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> pruning a Files collection
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 pruning a Files collection - 6/13/2008 11:51:45 PM   
  thorwath


Posts: 42
Score: 0
Joined: 12/6/2006
From: Grand Rapids, MI
Status: offline
Once I get a "file collection" from a folder, using code similar to:

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files

How do I then further prune the "collection" to, say, only include File objects who's name contains
*.dat? I know how to iterate on the above fc collection and check the .name property, but
then how do I create a 2nd "file collection" to which I add qualified file objects?

My confusion is really with the various "collections" returned by built-in functions, as I can't
find any info in online help (or my O'Reilly book) on how I create my own "empty collection" and
then add objects to it.

-Thanks, Terry

 
 
 
Post #: 1
 
 RE: pruning a Files collection - 6/14/2008 3:08:54 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi thorwath,

use an array - ReDim Preserve - or a dictionary - .Add - to collect
the file objects you are interested in.

Good luck!

ehvbs

(in reply to thorwath)
 
 
Post #: 2
 
 RE: pruning a Files collection - 6/14/2008 3:52:32 AM   
  thorwath


Posts: 42
Score: 0
Joined: 12/6/2006
From: Grand Rapids, MI
Status: offline
Thats what I used (a dynamic array). So I am not missing something on how to create
"collection" entities?

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: pruning a Files collection - 6/14/2008 5:16:39 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
I don't think so, but other people may know better.

(in reply to thorwath)
 
 
Post #: 4
 
 RE: pruning a Files collection - 6/15/2008 11:32:21 PM   
  mbouchard


Posts: 1863
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
To "prune" the original collection to a single file extension you can do this:







      
If you want to add to an array you could do this


      

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to thorwath)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> pruning a Files collection Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts