# Populate FileSet based on dynamic list

**URL:** https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084
**Category:** Discussion
**Created:** [January 22, 2009, 10:53am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084 "2009-01-22T10:53:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jonrobertson](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jonrobertson](https://www.finalbuilder.com/forums/u/jonrobertson)
#### Post date: [January 22, 2009, 10:53am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084/1 "2009-01-22T10:53:03Z")

</div>

Short question:&nbsp; Is there any way to populate a FileSet using an Include Filter list that is populated at run-time?

Scenario:

I have multiple, deployable, 7-zip archives.&nbsp; The files that should be in each archive are stored in a file named \*.lst.&nbsp; Each .lst file contains a set of filters defining the contents of the 7-zip archive, which each filter on a separate line.&nbsp; At run time, I want to iterate all of the .lst files, then build a FileSet containing the files that match the filters from the .lst file.

It would seem so easy using FileSets, File Contents Iterators, and Fileset Iterators.&nbsp; But I can't find a way of populating the FileSet Include Filters at run-time.

Thanks!

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [January 22, 2009, 11:02am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084/2 "2009-01-22T11:02:06Z")

</div>

Hi Jon   
  
 At this time the only way to populate the patterns and filters is at design time. I will look at adding scripting support so that it can be done at runtime… I can’t promise any timeframe at this stage… will have to look and see what is involved.

---

<div class="post-metadata">

### Author: ![jonrobertson](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jonrobertson](https://www.finalbuilder.com/forums/u/jonrobertson)
#### Post date: [January 22, 2009, 11:43am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084/3 "2009-01-22T11:43:46Z")

</div>

In case others are interested, here is what I'm attempting now:

I've created 14 "FileSpec" variables, named FileSpec1 through FileSpec14.&nbsp; I'm adding each of these as an Include Filter using the variable in the mask.&nbsp; I picked 14 because my largest list is 10 lines long but I don't want the script to break if a single line or two were added to the list.

The tricky part for me was getting the file contents into the variables.&nbsp; I'm using a File Contents Iterator to each line from the file (stored in a variable) to one of the FileSpec variables.

So in the OnBeforeEachIteration script event, I set a global FileSpecIteration = Iteration (event parameter value).&nbsp; This is a numeric index of the Iteration.&nbsp; Then I have a Set Variable action as a child of the File Contents Iterator, and in the BeforeAction event, I'm setting Action.VariableName = "FileSpec" & CStr(FileSpecIteration)

This is successfully setting each separate FileSpec variables to the corresponding line from the file.&nbsp; Be sure to initialize the FileSpec variables to a filename that will never be found, so that if file lists that are shorter do not end up adding wildcard masks to the Include Filter.

Still working on finishing the project, but I think this is going to work...

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [January 23, 2009, 8:17am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084/4 "2009-01-23T08:17:23Z")

</div>

Hi Jon   
  
 I should have a new build for you mid next week (Monday is a holiday here) with scripting support for fileset patterns and filters. I got half way through implementing it today but had other things to attend to.

---

<div class="post-metadata">

### Author: ![jonrobertson](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jonrobertson](https://www.finalbuilder.com/forums/u/jonrobertson)
#### Post date: [January 23, 2009, 3:15am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084/5 "2009-01-23T03:15:54Z")

</div>

Awesome Vincent! Thanks!   
  
 Although my hack is working, I think scripting support for FileSet patterns and filters is long overdue. I see the OleVariant object available via script, but I have no idea how to use it (or if it can be used).   
  
 Jon

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [February 6, 2009, 7:56am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084/6 "2009-02-06T07:56:02Z")

</div>

Hi Jon   
  
 [https://www.finalbuilder.com/downloads/finalbuilder/620/FB620\_1303.exe](https://www.finalbuilder.com/downloads/finalbuilder/620/FB620_1303.exe)   
  
 This build has the scripting support. I haven’t had chance to document some parts that will need documenting. The method to add filters can return objects of differing types, however the code completion parser has no way of knowing what types they are (and I didn’t want to hard code that in).   
  
 The trick is to give the code completion the type :   
  
 dim filter   
 set filter = Action.FileSet.Filters.AddFilter(“Contains”) 'as FileSetFilterContains   
  
 Notice the [’ as FileSetFilterContains] comment on the end of the liine   
  
 This gives the code completion engine the type for filter.   
  
 Valid types are :   
  
 FileSetFilterContains   
 FileSetFilterPathContains   
 FileSetFilterAttributes   
 FileSetFilterSize   
 FileSetFilterDateTime   
  
 The valid parameter values for AddFilter are available in code completion… note that they are actually strings so will need double quotes.   
  
 Hopefully there’s enough there for you work with.

---

<div class="post-metadata">

### Author: ![jonrobertson](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jonrobertson](https://www.finalbuilder.com/forums/u/jonrobertson)
#### Post date: [February 6, 2009, 3:55am UTC](https://www.finalbuilder.com/forums/t/populate-fileset-based-on-dynamic-list/1084/7 "2009-02-06T03:55:49Z")

</div>

&nbsp;

> Posted By Vincent Parrett on 06 Feb 2009 12:56 AM   
>   
> Hopefully there's enough there for you work with.

Sounds awesome Vincent.&nbsp; Thank you so much.  
  
I won't have a chance to try it today, but I'm anxious to give it a shot as soon
