Comment on page
TAP Studio - How to open all desired files of a certain type in a folder
Opening files is a key feature that any RPA robot should be able to do. It is a pretty simple process and it’s not going to burn through your resources, unlike those 32 tabs of chrome you have open but not using.
But what if you want to open more files at once or want to have the robot open each file one by one and make some changes?
In this post you are going to find out how you can automate this process in Tap Studio, the perfect RPA IDE in which you can build any kind of robot to your heart’s desire.
First step is to open the Tap studio and go to your project or create a new one from scratch.
After you create your new project, you will be met with the following screen:
Here you will want to create a new variable by clicking on the plus icon in the variable tab located on the right-hand ribbon.
Do the same once again but this time create a variable of type List to hold the list of files you want to work with.
Once you created the variables, press the three dots under the value column and write the path to the folder containing your files.
Make sure to use quotation marks while writing the path and don’t forget to add an @ at the beginning, like this:
Go and search for the custom C# script and add it to the new sequence, open it and press the “Generate Code Starter” button.
Here you will need to write a bit of code. Firstly add using System.IO; next to the other libraries at the top.
After adding the System.IO library, write the following snippet of code inside the main function:
foreach (string item in Directory.GetFiles(path, "*.docx"))
Now that we have a list of all the .docx files we can do whatever we want with it. We can either work with the files, modifying things in the background with actions such as “Replace” words/phrases in the documents, or we can open all of them one by one and set up some instructions for the UI Browser.
In this example we will follow the latter option and open all docx files.
Create a “i” variable and set the type to int32 with a value of 0.
Create a new sequence and add a Start Process Action with the Process path set to Files[i]
This means you want the path to the document stored in the position i of the list.
Create an new sequence with the Action “Assign Value” and set the Input to “i” and the output to “i+1”
For the final step you have to set the condition of the transition, (the arrow that goes from Start process to Assign value) to:
i <= Files.Count()
This will assure that the loop stops as soon as all the files have been opened
This will only open the files one by one but in the 3rd sequence, you can add whatever actions you want the robot to perform on that file and make your life easier.
I hope this tutorial helps you in your journey to become a Tailent RPA Developer and I will see you in the next post!