For each loop stops at the end of window view (more files in folder)

Hi UIPath community,

I want to create a loop that goes through each file in a folder and double clicks to open it.

I have assigned a variable files = Directory.GetFiles(filepath)
and a variable fileCount = ‘0’
Then in a For Each item in files loop I’ve sent an action to double click the name bit. The selector is dynamic with automationid={{fileCount}}
and the final action is to assign the next id to fileCount = (Integer.Parse(fileCount) + 1).toString

When I start the automation it works for all the files in the window view which are about 20 of them (attached). However after that it stops and can’t find the next element in the list (in reality you will need to scroll to see it in the window view). How can I go around this and have it go through each of the 840 elements in this folder?

My full selector is:



Thanks in advance for all your help!

And here is the selector visible:

wnd app=‘explorer.exe’ cls=‘CabinetWClass’ title=‘archive legal-database case law’ />
ctrl name=‘Items View’ role=‘list’ />
ctrl automationid=’{{fileCount}}’ />
ctrl automationid=‘System.ItemNameDisplay’ />//

Have you tried just selecting all, right click, open?

Hey Matt. I have thought of just opening them in advance but this is the start of a longer sequence. The sequence will be to open each file (they are all html), find a specific text on it, copy the data and add it to an excel sheet.

If I can’t find another option the back up will be to open them all in advance and then use hotkeys to switch between tabs but considering how many the files are I think that will slow down the automation. Plus I then have to do that very time I want to repeat this instead of it being part of the full automation.