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.
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.
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- 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.
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
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?
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.
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.