Showing posts with label names. Show all posts
Showing posts with label names. Show all posts

Thursday, March 8, 2012

Can I use the foreach loop to obtain the sub folder names within a folder?

I have a set of folders with the following structure:

MainFolder

1999

SpreadsheetA.xls

SpreadsheetB.xls

SpreadsheetC.xls

2000

SpreadsheetA.xls

SpreadsheetB.xls

SpreadsheetC.xls

etc.

Is there a way that I can use the foreach loop container to loop the sub folders? My plan was to get the folder name and path into a variable, use this to build the connection string for each file in this folder, carry out the upload for that folder, then move onto the next folder and do the same thing, but I cannot see a way to do this.

Thanks,

Sam

If the list of folders is known and finite then you can just type them into the ForEach Item Enumerator.

If the list changes then you'll need to do something a bit cleverer. Like writing your own Enumerator.

-Jamie

|||

sam2005 wrote:

I have a set of folders with the following structure:

MainFolder

1999

SpreadsheetA.xls

SpreadsheetB.xls

SpreadsheetC.xls

2000

SpreadsheetA.xls

SpreadsheetB.xls

SpreadsheetC.xls

etc.

Is there a way that I can use the foreach loop container to loop the sub folders? My plan was to get the folder name and path into a variable, use this to build the connection string for each file in this folder, carry out the upload for that folder, then move onto the next folder and do the same thing, but I cannot see a way to do this.

Thanks,

Sam


Have you tried the 'traverse sub folders' option on the ForEach object (on the collection pane)