Hello, How to rename attached file before download to a folder


as shown, i am using for each email and inside it i have used save attachment activity.
now how to rename the attachment name before saving it into the folder path.
for example, id the file name is “GL” i need it to be “1-gl” also if there is more than one attachment in the email the robot do the same for them all to add serial before the file 1- 2- 3-
and so one.
appreciate the help :slight_smile:

1 Like

Hi @mohamed.saty2012

After saving to the folder only you can rename the file by using Rename file activity, give the same downloaded file name in from field and give the name what you want to change in To field in Rename field activity.

Hope it helps!!

1 Like

@mohamed.saty2012,

No way to rename attachment name while saving it. You should download it to intermediatory folder first and use Move File activity to rename and move to final destination folder.

Thanks,
Ashok :slight_smile:

1 Like

could you please show me how step by step.

Hi @mohamed.saty2012

Try this

Sequence2.xaml (15.6 KB)

Regards,

1 Like

we would recommend to rename the attachment after the saving.
Technically we can do also (recommended to work on a copy)

1 Like

it works alone but once i add it into the automation i am working on it it gives me this error.

is it something wrong i did?

@mohamed.saty2012

Can you try below and make sure you have to create output of Save Email Attachments activity

1 Like

sorry for the late replay i didn’t have access to my laptop due to some technical issues i will try today and inform you thanks for the support.

UiPath doesn’t directly rename files during the download process. However, you can achieve this using a two-step approach:

  1. Download the attachment to a temporary location.
  2. Rename the downloaded file and move it to the desired folder.

Here’s how you can implement this in UiPath:

1. Download with Temporary Location:

  • Use the “Save Attachment” activity.
  • In the “Filename” property, specify a temporary path within your project folder or a designated temporary folder. You can use string manipulation functions to generate a unique temporary filename if needed.

2. Rename and Move:

  • Use the “Move File” activity.
  • Set the “From” property to the path of the downloaded file in the temporary location.
  • Construct the new filename and destination path in the “To” property. You can use string manipulation functions here to define the renaming logic (e.g., adding a prefix, timestamp, etc.).

Here are some additional points to consider:

  • Make sure the temporary folder has enough space to store downloaded files.
  • Handle potential errors during download or moving operations using “Try Catch” blocks.

By combining these steps, you can effectively rename downloaded attachments before placing them in your desired folder within UiPath.

1 Like

Thanks all for the amazing support.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.