I’m currently working on a project where I need to retrieve file paths from a folder and insert them into a specific column named “QR Code” within an Excel sheet. I’m facing a two-fold challenge and would appreciate guidance:
Retrieving File Paths:
Is there an activity in UiPath that allows me to retrieve file paths from a specific folder?
How can I use this activity to get the path for every file in the folder?
Matching and Inserting Paths into Excel:
Once I have the file paths, I want to check if the file name matches any value in the “Customer Name” column of the Excel sheet.
If there is a match, I would like to insert the file path into a column named “QR Code” at the corresponding row.
Note: It’s possible to have multiple files with the same file name in the folder, so there may be multiple file paths inserted into the “QR Code” column for a single row.
Any insights, suggestions, or sample workflows demonstrating these tasks would be highly valuable. Thank you in advance for your assistance!
→ Take an assign activity and create a Int32 datatype variable called Count.
- Assign -> Count = 2
→ Use Read range workbook activity to read the Excel and store in a datatable called Input_dt.
→ Use for each row in datatable activity to iterate the each row in the Input_dt.
→ Inside for each Insert assign activity and create a String variable called QR_Codes.
- Assign -> QR_Codes = String.Join(Environment.NewLine,(From file In Arr_Files
Where Path.GetFileName(file.ToString).Contains(CurrentRow("Customer Name").ToString)
Select file
).ToList)
→ Take write cell workbook activity to write the QR Codes in the cell. In the Cell Field give like this “C”+Count.toString
→ Take an assign activity to increment the Count Variable.
- Assign -> Count = Count+1
Check the below workflow for better understanding, 2024.xaml (20.1 KB)
I hope you find the solution for your query. If yes mark my post as solution to close the loop. Else ask your queries here I’m happy to help… @sasadrinksprite
Thank you for your reply; it’s effective. However, there’s a specific scenario I’d like to address. In the event that I have multiple files with the same name, I would like these file paths to be inserted under the same name. For example:
For these two file paths that share the same name within the ‘CustomerName’ column, I wish to have them added to their respective cell, separated by a comma [,**]. The desired outcome in’QR Code’ Column is as follows: [“C:\Users\Desktop\Mahesh Kankatala.xlsx”, “C:\Users\Desktop\Mahesh Kankatala - Copy.xlsx”] ."
The above developed workflow work, if one customer name contains multiple files and write those file paths into that corresponding cell. To seperate with comma between multiple file paths, Then change the LinQ expression as below
- Assign -> QR_Codes = String.Join(",",(From file In Arr_Files
Where Path.GetFileName(file.ToString).Contains(CurrentRow("Customer Name").ToString)
Select file
).ToList)