How to rename a file to its corresponding value (210.4 KB)

You can Refer This one also… made some changes in assign activity

But is it hardcode it, cause in future lets say i have more file with name needed to change to its key how can i do it?

because u created a seperate excel for it how do i no create anything extra but just use the files given

@Helpmepls To replace the file name “1. File A1” with “1. File John” in a DataTable where the first column contains the key “A1” and the second column contains the value “John,” you can use UiPath. Here’s a step-by-step guide:

Assuming your DataTable looks like this:

Key Value
A1 John
A2 Alice
A3 Bob

You can use the following steps:

  1. Loop Through DataTable:

    • Use a ‘For Each Row’ activity to iterate through the DataTable.
  2. Replace Values:

    • Inside the loop, use an ‘Assign’ activity to update the value in the first column with the value from the second column.
    • For example:
      • row("Key") = "1. File " + row("Value").ToString
  3. Update DataTable:

    • Since DataTables in UiPath are mutable, the changes you make to the rows will automatically reflect in the DataTable.

Here’s the workflow in UiPath:

- For Each Row in DataTable
  - Assign row("Key") = "1. File " + row("Value").ToString

This will update the DataTable to replace “1. File A1” with “1. File John” and similarly for other rows in the DataTable.

But my excel file which i originally sent the key is not exactly A1, but instead to be , how can i only use the 2nd and 3rd position the the A1 in the to change instead


Please try this


Try these steps

Get the Datatable.
DataTable dtFiles = GetDataTable(“dtFiles”);

Add a new column to the Datatable to store the new file name.

Iterate through the Datatable and replace the file name in the new column with the corresponding value from the second column.
foreach (DataRow row in dtFiles.Rows)

string oldFileName = row[“FileName”].ToString();
string newFileName = row[“Value”].ToString();

Replace the file name in the new column.
row[“NewFileName”] = newFileName;

Save the new file name column to the Datatable.

Set the output variable.
SetVariable(“dtFiles”, dtFiles);

Thank you

1 Like

1.File- A2.docx (15.4 KB)
MASTER FILE.xlsx (19.5 KB)
1.File- A1.docx (15.3 KB)
Hi could you send me your UiPath based on these files using masterfile input to change the file names

Any updates, thank you


Can put in UiPath as i not sure pls do update me thanks