"Sequential Execution of Files in UiPath using 'Run' Button"

Suppose I have a folder that contains a list of files numbered from 1 to 20, and I want to sequentially open each file, one by one, whenever I click the “Run” button. For instance, after pressing the “Run” button once, the first file (File1) should execute, and upon completion, the file should close. Subsequently, on pressing the “Run” button again, the second file should execute and close. How can I achieve this in UiPath?


Welcome to the community

You can store the sequence number to asset or an excel and whenever you run…you can get the number and then increment by 1 and check for the filename with that seuqence number…

Hope this helps


Hi @cina

  1. assign a variable “filePath” to the path of the directory containing the files.
  2. Use “Directory.GetFiles” activity to retrieve the list of file names in the directory. Store the result in a variable named “filesList”.
  3. Create a variable named “curIndex” and initialize it to 0.
  4. Use a “Do While” loop to repeatedly perform the following steps until the “currentIndex” reaches the end of the “filesList”.
  5. Within the “Do While” loop, use the “Start Process” activity to open the file with the path “filePath + “” + filesList(currentIndex)”.
  6. Use the “Wait For Exit” activity to wait for the process to complete.
  7. Use the “Close Application” activity to close the file.
  8. Increment the “curIndex” by 1.
  9. Use the “Delay” activity to add a delay between opening each file.

I hope this will resolve your problem.