Can it only be added by enumerating all the items in the folder?
Function GetItems(Path, Files)
Dim cmd
Set cmd = DOpus.Create.Command
cmd.SetSource Path
cmd.RunCommand "Select " & Files
dopus.output cmd.filecount ' output 0
Set GetItems = cmd.Files
End Function
set textfilles = GetItems("d:\temp", "*.txt")
If you want a VBScript collection/list/array/etc. of items (not a File Collection like Tools > Find Files generates), then you would need to enumerate the folder. But that's only a few lines of code using the objects Opus gives you, including the wildcard filtering.
I think I have an example somewhere on my other PC, so if you need it please ask and I'll look for it.
(I'm assuming the Select command here is just for the example. If you wanted to select *.txt, you wouldn't need to pass a file list at all.)
Option Explicit
Function OnClick(ByRef clickData)
Dim folderEnum, folderItem, wild, strSet, strItem
' Create some kind of collection object.
Set strSet = DOpus.Create.StringSetI()
' Create a *.txt wildcard.
Set wild = DOpus.FSUtil.NewWild("*.txt", "f")
' Enumerate our tab's current folder
Set folderEnum = DOpus.FSUtil.ReadDir(clickData.func.sourcetab.path)
Do While (Not folderEnum.complete)
Set folderItem = folderEnum.Next
If (Not folderItem.is_dir) Then ' Ignore directories
If (wild.Match(folderItem.name)) Then
' Add this one.
strSet.insert(folderItem)
End If
End If
Loop
' Output the paths of everything we added, to the script log.
' (Or do whatever you want with them.)
For Each strItem In strSet
DOpus.Output strItem
Next
End Function
If you want it to be recursive (find matching files in sub-dirs), just change the ReadDir line to add the "r" flag:
Set folderEnum = DOpus.FSUtil.ReadDir(clickData.func.sourcetab.path, "r")
I didn't know about the FSUtil.NewWild() function..
I use the following (which could probably be simplified using NewWild()) which takes
a path (not a lister tab) and populates a result set with all matching files.
It might be useful to someone.
It has the minor advanage that it doesn't depend on the current lister state, or change it.
function GetItems(Path, pat)
dim result, files, reg, match
pat = Replace(pat,".","\.")
pat = Replace(pat,"*","[^\\]*")
pat = Replace(pat,"?","[^\\]")
set reg = new RegExp
reg.Global = false
reg.IgnoreCase = true
reg.pattern = "^" & pat & "$"
reg.pattern = "\\(" & pat & ")$"
set files = DOpus.FSUtil.ReadDir(Path, false)
set result = Dopus.Create().Vector
Do while not files.complete
item = files.next
set match = reg.execute(item)
if match.count then
result.push_back(match.item(0).submatches(0))
end if
Loop
set GetItems = result
End Function
set textfiles = GetItems(DOpus.FSUtil.Resolve("/downloads"), "*.zip")
for each item in textfiles
DOpus.Output item
next