
Static vs. Dynamic Files Collection
Attached is a script component (FileFilter.wsc)...
Methods:
GetFiles(oFolder,sFilter)
Returns a sorted array of filtered file objects
Properties:
fso
shell
Usage example:
set ff = createobject("filefilter.wsc")
set fo = ff.fso.getfolder("c:\")
'
'Tip: use *.* if what you REALLY want
' is the sorted array equivalent
' of the Files collection of the
' passed folder.
'
arFiles = ff.getfiles(fo,"*.txt")
for each fi in arFiles
s = s & br & fi.path
br = vbcrlf
next
msgbox s
--
Michael Harris
MVP Scripting
I've dealt with this problem by first dumping the file collection into an
array and then just iterating through the array to do what I need to do on
the files. This also lets you filter what you put into the array so you
only do your work on the files you want.
I tend to get nervouse moving files around, I'd rather work with an array.
I use this idea to split large folders down to cd burning size and keep the
files I want in the correct folders.
a= Array()
nCount = 0
For Each Item in <files collection>
Redim Preserve a(nCount)
a(nCount) = Item.name
nCount = nCount + 1
Next
For nNewCount = 0 to Ubound(a)
filename = a(nNewCount)
<do bad stuff to file>
Next
--
David Hamel
NBT Inc.
Quote:
> Moving the files is an option I'm considering. I agree with the count
> option that there's no guarantee that the files will be processed in
order.
> For the interim I will probably move the files to a new directory if
there's
> no static forms collection. Thanks for your input.
|
|
FileFilter.wsc
2K
Download
|