I had created an automation where I was moving multiple files from single folder to another folder along with renaming them.
Now, I wish to scale up the same automation where I want to move multiple files to multiple locations and rename them.
I am using a reference excel file to add input path and output path and rename suffix column. This is used by UiPath to determine which files is to be moved to which folder along with what naming convention.
The challenge I am facing is I am unable to loop it for multiple folders.
as @Rounak_Kumar1 suggested, you would need to use the For Each Row activity to loop through each row in the excel file and utilse the data in each column to complete your actions:
i.e.
For Each Row in Datatable
Input = Row.Item("Input Path").ToString
Output = Row.Item("Output Path").ToString
Suffix = Row.Item("Rename Suffix").ToString
NewDestination = Output.Insert(Output.LastIndexOf("."c),Suffix)
Move File Activity - From (Input) To (NewDestination)
When you are moving the file, same exact file name should be there
you are keeping the file path in excel right
then you should keep move file it will move one by one just like it is reading row by row(File Path) with the help of For each row
Code in “From” of move file: CurrentFile.FullName
Code in “To” of move file: Destination.ByField(“Destinatination Path”)+system.Io.Path.GetFileNameWithoutExtension(CurrentFile.ToString)+Suffix.ByField(“Suffix”)+system.io.Path.getextension(CurrentFile.ToString)
You dont need so many for each row looped inside each other - just one For Each Row for the excel file for the whole sheet rather than specific columns
You then use the column names per row to do the move file.
For Each Excel Row (Set For Each to (CurrentRow) and In Range to ([Excel] Sheet1)
Input = CurrentRow.Item("Input Path").ToString
Output = CurrentRow.Item("Output Path").ToString
Suffix = CurrentRow.Item("Rename Suffix").ToString