Download and save on Specified Folder

Hello Forum, Today i have the assingment to create a robot which download some audio files and then saves them in a new folder with specified name.

I was wondering which might be the best way to do it. The first thing a thought was using a create folder with the specified Agente name and then use a move file activity to move the file to the specified folder. Let me know what you think.


In my opinion:

1 - Validate if “Agent Folder” already exist (use path Exist activity);
1.1 - If doesnt exist, create.

2 - Download the file
2.1 - You can choose de destination folder on download?
Yes - Download on agent folder.
No - Use this ((Directory.GetFiles().[Select](Function(x) New FileInfo(x)).Where(Function(f) f.Extension.Equals(“”)).OrderByDescending(Function(x) x.LastWriteTime).Take(1).ToArray()(0).ToString()) To get de last downloaded file.
Use “move file activity” to move the file.



Hi @Luis_Fernando,

My scenario would be as follows, respectively.

1-Datascraping (I will be able to create a loop by reading the table and use the data in the table so that the file is unique.)
2-Delete Download File (If you are downloading to the download folder, I will clean this folder before each download)
3-Click activity for download (I try to find the index in the click selector and get this index from the for loop. Since the index will increase with each cycle, it will move to the next file each time.)
4-Wait for Download (I’ll make sure the file lands.)
5-Copy File activity (In each cycle there will be a file in the download folder. Directory.I get it with Directory.GetFiles("download file path","*.mp3)(0) and move it by naming it with the values in current Row.)


1 Like

Hello @muhammedyuzuak, the thing is that

1- I dont think is a good practice to delete all files y the download folder, since this is not a practice that every machine who is going to work this automation would do.

2- In the other hand every time it download the file. The file doesn’t appear as the first file on the folder, sometimes is appears in the 4th or 5th position.

3- The main issue i’m having is that some downloads files results finish being Error fo some reason on the web. And my struggle is identifying the current download, if it’s result is error or correct, and if it’s correct, then find the file and move it to the folder.

Look what i did…

The main problem i’m having is with the if statement. When the file downloads correctly it has no problem, but when the file download Error occours it doesn’t seem to e able to identified the text and go to the then side of the if. Check this out and let me know what you think

Try this

So what if other automations won’t do this? The Downloads folder is specific to the Robot account. Why would it be a problem to delete everything that’s in there before the automation starts downloading files?

Their Wait for Download is poorly designed. Just do your own with a Do While, using “NOT File.Exists” as your condition.

Okay, another suggestion.

If you know the file name, you can validate the file size. If it’s 0kb, it means there was an error.


This is a unattended robot, so having to be attended just to erase a folder is not a good practice, taking ito account that this robot runs on sleep hours.

Okay, another suggestion.

If you know the file name, you can validate the file size. If it’s 0kb, it means there was an error.


I found something else, what i discovered is that i was using a get textactivity on the error download window to decide if the download was a error or not, and what i discovered was that the window selector is never available. So what i did is erase the if statement and sorround the activities in a try catch, so when an download error occurs it throws an error and the try catch catches the error and just gives a log message and continuos with the next. But what i saw is that it doesn’t catches the error when occurs. Someone knows why?

Why don’t you just use the path exist activity?
When the file is being extracted, it doesn’t have an extension yet, so the path exist will be false.
Put it inside a while.

Turn on the filepath prompt feature in the download options on the browser you are using. In this way, you can download and name a folder you want.

I agree with that. You can make sure that the file is downloaded with count and exist in a dowhile.

This situation will also disappear when you specify the file path.


Can you also share the catch field ?

You can remove all the files from the Download folder in an unattended automation.