Hi guys, I’m wondering if it is possible to loop through a folder and for each file perform a set of activities? I have already set up Directory.GetFiles with the folder path and then added a for each activity to filter through each file, but each file is a template that then needs to be filled out. How do I dynamically open each file and fill out the information?
Hi @mojo001
Is it a Excel template?
then you can you “Excel Application Scope” to open each Excel file. Within the Excel Application Scope, you can use activities like “Read Range” to read the data from the file, perform necessary operations, and then “Write Range” to save the modified data back to the file.
Hello Mojo,
- Use the “Directory.GetFiles” activity: As you’ve already done, use this activity to retrieve a list of files in the folder you want to process.
- For Each File: Use a “For Each” activity to iterate through each file obtained from the folder.
- Open Each File: Use activities such as “Start Process” or “Open Application” to open each file in the appropriate application. For example, if your files are Word documents, you can open them using Microsoft Word.
- Fill Out Information: Depending on the type of file and the information you need to fill out, you may use different methods. For example:
- For text-based files (e.g., Word documents or text files), you can use activities like “Type Into” to input text.
- For PDF files, you might need to use OCR (Optical Character Recognition) activities to extract and input text.
- For Excel files, you can use activities to directly write into cells.
- Save and Close File: After filling out the necessary information, save the file and close it using appropriate activities.
- Repeat: The “For Each” loop will continue until all files in the folder have been processed.
Please let me know if your issue resolves.
Happy Automation.
The question is far too vague, you have to know specifically what you want to do with the files.
@mojo001
You can use “for each file in folder” activity to loop through each file .
@mojo001 ,
Check the above thread i have attached a solution