A2019 Loop through files in folder

 RPA | A2019 looping through files in folder| Automation Anywhere - Part-35

A2019 loop files in folder  - In this blog we will be discussing how we can loop through all the files that are present in the folder located at a specified location defined by the user and display the file names using the message box command using A2019 Automation Anywhere.

Before we begin the main discussion of how to loop through all files in folder let us first discuss the main motive behind creating this article. The main motive for creating this article is that this article will guide you through the steps that are required in order to loop through all the files that are present in the folder and this is one of the real scenario that every developer has to go through while building the end to end process in the real life world.

So to begin the discussion we will first go through the steps that we need to follow in order to build the loop through files in the folder bot which are given below:

  • Create a variable called vFolderPath. We can assign the value to this variable in two ways first method is when we are creating the variable under that there is a field called default value so we can provide the default value for the folder in that field from which we want to pick up the files. The second way is to drag and drop String Assign action and under that in the properties section pass in the value and create a string variable to store the output.
  • Now drag and drop loop action and in the properties section in the iterator drop down menu select for each file in folder as the iterator, then in the folder path field give the variable name that we have created in the previous step and last but not the least store the output in a dictionary variable data type. Select the wand icon to create a dictionary variable data type or click on the variables pane and click on the "+" icon to create the variable.
  • Inside the loop action drag and drop the message box action and in the enter the message to display field select the dictionary variable and it will ask for the dictionary key upon selecting the dictionary variable so in the dictionary key pass in name as the key for the file names and for file extension pass in the extension as the dictionary key.
  • Click on save button to save the task.
  • To run the task click on the run button. Once we click on run button the bot will start running and the Bot Agent will communicate with the machine on which the bot is running and all the file names along with the extension will be displayed one by one in the message box.

Below is the screenshot for the code snippet for the steps that we have discussed above.

LoopFilesInFolder

So with that we have come to the end of our article where we discussed the steps that are required in order to build the loop through all files in folder bot development.

If you face any issue regarding any steps that we have discussed above then please feel free to reach out to me with your queries and I will be more than happy to resolve all of your queries.

Before I close out this article it's a small and humble request to share your feedback once you go through this article as the feedbacks you share is of utmost importance to me and if you want me to create article on any topic related to automation anywhere please feel free to tell me about that as well.

Comments