How to Rename a downloaded file and save its path into existing column of an excel

Hie,
I am a rookie at Uipath and unable to solve this issue. I have a datatable with 6 rows.
for each row, i need to make web automation and download a pdf thereby downloading 6 pdf files for 6 rows.

for each row, i need to make web automation and download a pdf into specific folder called “PDFs” thereby downloading 6 different pdf files for 6 rows.

For each row, i need to rename the downloaded pdf file, and save it to a cell of “attachment_path” column in datatable. So that, in later i can send 6 different attachments to 6 "mail_Id"s of that datatable.

I need to rename the topmost file generated in “PDFs” for each row. like “PDFs”(0) and save its path into excel before generating next pdf.

please help. any idea is genuinely appreciated.

Hey @Srikavya_n

I tried to make a simulation from how I understood the process described.
PdfManipulation.zip

  1. Created a CSV file to mimic the one described by you - in this, after the robot runs we will see the update take place.
  2. The robot asks you to choose which pdf you would like to download - out of the 6 pdfs.
  3. Folder “Web” stores 6 pdfs as “they were on the web”.
  4. Folder “PDFs” is the download folder from your description. The bot simulates a download action from “Web” folder to “PDFs” folder by using a copy action.
  5. The bot renames the file “downloaded” in “PDFs” folder as desired.
  6. The renamed pdf file path is updated in the data.csv. Open data.csv after running the robot to see the changes take effect.

Re-start the robot and choose another pdf to download. After running it, check the updated results in data.csv

Delete the files from “PDFs” folder and remove the data from “attachment_path” column if you would like to start the process from the beginning.

  • You will need a column which correlates the pdf downloaded with the datatable - in my simulation, this was PDF_index. In real-world, maybe it will be something like PDF_link.

Hope I got close enough to how the process will run. :slight_smile: Cheers! (36.4 KB)

1 Like

Thanks a lot for the immense help. It made my day.

But i do have a few concerns here.

my pdf attachment files get saved automatically into a specied folder in the project so I dont need to move it somewhere else. How can i rename without moving the pdf file

Also the folder “PDFs” path has been saved as a key-value pair in a configurationDictionary<String,Object>.

like input_config_dictionary(“save_pdf_parh”) = “PDFs” folder path.
How can i save the 1st file in the “PDF’s” folder into excel’s column with dictionary(“save_pdf_path”) in for each row loop

i tried to assign like this
datarow(“attachment_columnn_name”) = config_Dictionary(“save_pdf_path”)(0)
unfortunately, uipath doesnt allow late binding (on strict).

I can share few snapshots or xaml code if you need futher clarity

Hey @Srikavya_n

Actually, Move File used in my workflow works as renaming the file - it “moves” it to the same folder, but to a different name. Even if a little counter-intuitive at first, this is the way to rename a file in UiPath.

The for each should look something like this:

For each row in datatable:

counter = datatable.indexOf(row)

dynamic_PDF_name = “pdfDownloaded” + counter.ToString + “.pdf”

row(“attachment_path”) = dictionary(“PDFs_folder_path”).ToString + dynamic_PDF_name