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.
@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 download folder (get all the files into array by Directory.GetFiles) then use move file activity.
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 - 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