I have a list of PDF files where the file names are IDs of the employees and an excel file which contains the list with Employees along with their IDs.
I want to compare each PDF file names (ID) against the IDs in the excel to retrieve the employee name of each IDs, and rename the PDF file as “ID-Employee name”
- For each file you can try this ( add For Each as well )
Read file names from excel into a datatable (ReadRange activity)
Search the PDF file name in the datatable (Lookup Data Table activity)
- Also, I add another suggestion and hope it might help you:
Follow below steps:
Assign an array variable(say Files) to Directory.GetFiles(“FolderPathWherePdfFilesAreStored”)
Use read range activity and store your excel data into a datatable variable(say dt1)
For each row in dt1
{
For each File in Files
{
Assign a string variable(say Name) = row.item(“ID”).tostring() + “.pdf”
if(File.substring(File.LastIndexOf("")+1) = Name)
{
Assign a string varialbe(say NewName) = row.item(“ID”).tostring() + “-” + row.item(“EmployeeName”).tostring() + “.pdf”
Use move file activity with the properties as below:
from: File
To: File.replace(Name,NewName)
Place a break activity here
}
}
}
For ID, EmployeeName are the column names of the excel file or replace them with whatever column names you like