Can I make a double "for each" loop?

Hi guys, I hope the solution to my question hasn’t appeared elsewhere.

So I have one folder that contains many other folders which has multiple text documents inside:
(3 layers in total: BIG FOLDER > Folder > many .txt)
And I want to extract information from ALL text files in all folders into one excel spreadsheet.

I already have a workflow with a “for each” loop to deal with only 1 folder of many text files, and it looks like this:


I first assigned a variable to the path of the folder, then I used a “for each” activity and passed the variable to it so that each item in the folder will perform a subsequent action.

Going back to my workflow, (BIG FOLDER > Folder > . txt), Is it possible to set up a loop so that for each text file in each folder in the BIG FOLDER can be looped? Eventually, I want all text folders be transcribed into an excel file

Hi @Ben_siu

Check Out the Variable Type of Files → It should be in Array(String)

Regards
Gokul

also have a look here:

Directory.GetFiles(MyDirPathVar,"*.*",SearchOption.AllDirectories)

taken from:

maybe the nested loops can be avoided

Hi there, hope you are doing well. You can do something like given below

And I hope it will solve your issue

Hi, thanks for your answer.

May I know where I can find the “For each folder in folder” activity?

Hi @Ben_siu

In the Activities panel Go and check

Regards
Gokul

Why don’t I see this activity? I am using Studio instead of studioX does that make a difference?

Update the Uipath.System.Activities in the manage package @Ben_siu

Thanks! I have the activity now! Thanks so much!

Great @Ben_siu

Do you have any other queries related to this topic

Not for the time being, thanks for the help!

Oh, sorry, one more thing.

My workflow looks like this now, is there a way to store the name of each file as a string as the loop goes? Should I use the assign activity to do so?

Here it is in the System activities

Hi @Ben_siu

You can check the screenshot

Need to pass the extension → example “*.txt”

For getting the file name use → CurrentFile1.Tostring

image

Regards
Gokul