Download a file from the web with random name and rename into a folder


I have a bot which will download a file from a webpage. This automatically downloads to my downloads folder. I want to rename the file and move it to another folder.

I know how the move file function works, however, the name of the file changes each day. Therefore, I cannot use a simple move file function with path\downloads\file.csv to newpath\file.csv

Is there a way to download a file and rename and move the location? There are always multiple files in my downloads folder and I want to do this on the most recently downloaded file.

Hy @scottwilsher, welcome to the UiPath Community.

Please check the ‘download file’, it is exactly what you need. You will provide the download folder and UiPath will return you the file name

Please like my answer and mark it as a solution if it is ok, it helps me :slight_smile:
Any more questions please let me know


@scottwilsher First solution would be remove the automatically download option disabled. It will give you a control to save that file with your need(e.g. location and name of file).
Second solution would be loop over :grin::wink: download folder (get all the files into array by Directory.GetFiles) then use move file activity.


This is for downloading files from Salesforce. My files are being downloaded from elsewhere. Is there something similar?


I tried to do that but when I chose type into function for the file name, the bot would not type. The bot would just get stuck.

Do you know why?

If you have a sequence example that would work, I would appreciate that.

Hy @scottwilsher, it should for any web downloads, check it out and let me know if it works

@scottwilsher looks like many of are having the same problem with type into activity. Could you give a try with set text activity :wink:

I just tried set text activity and the bot still doesn’t do anything at this stage. Do you have an example workflow?

The download I do each day is for a different file name which is randomly generated. I do not know the name of the file each day. However, it is downloaded in the same way each day. Therefore, this function I don’t think will work.

@scottwilsher please work on your selector, take inside block of the File input box

Hy @scottwilsher,

The activity will return you the file name so you can work with, ok?

sorry I do not understand what you mean. I have tried the set text and type into in a few different ways and can’t get it to work.

@scottwilsher while using type into or set text activity indicate element inside the File input box

Hy @scottwilsher, the activity returns the downloaded file name. Did you tried to use it? Please share me your screenshot

@scottwilsher - I never just click on a file to download it, as there is then one-time setup that needs to be done on each robot & there are a variety of issues that can come up. Instead I would recommend downloading files in one of these 2 ways:

1). Right click on the link, select save as, type in the full file path (including extension) for where you want the file to be named & saved in the ‘file name’ portion of the save as dialog box that pops up. This is the most used method as it will always work as long as you don’t require it to be background automation.

2). Use the http request activity (part of the uipath web activities package) to save a file. This is the quickest method and works in the background, but requires re-sending authentication if it’s a secure environment, or if it’s a public download (e.g. something found on a website that doesn’t require logging in) then it works perfectly too. Just save the URL from the link by using the ‘Get Attribute’ activity, then use the http request activity and supply the URL as the endpoint. The full file path (including extension) of where you’d like to save the file should be put in the ResourcePath poriton of the http request activity

Hi @scottwilsher

refer the following thread for the same to get the latest file downloaded to particular folder

May this help you to solve your issue

Mark as solution and like it if it helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer: