Only the files that starts with Report needs to fetched which are present inside the folder with name as “Execution_YYYYMMDD”
Only last 5 created folders needs to be accessed.
We can not apply weekend logic alone as there might be some exceptions for holidays in weekdays so we just want to access last 5 created folders and get the one file starting with “Report_”
It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.
First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.
You can check out some of our resources directly, see below:
Always search first. It is the best way to quickly find your answer. Check out the icon for that.
Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.
Topic that contains most common solutions with example project files can be found here.
Read our official documentation where you can find a lot of information and instructions about each of our products:
Meet us and our users on our Community Slack and ask your question there.
Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.
Thank you for helping us build our UiPath Community!
Yes, I am able to use that activity but my concern is related to getting the only files which are desired.
Currently, I am able to download the entire folder “Execution_YYYYMMDD” as shown above and then I am deleting the other files except the required one.
My main concern is with the “extracting the last 5 created files from inside the folder” Note: We can not use directly the last 5 days as their are weekends and holidays
Make sure the type for the For Each matches the output of the Enumerate objects activity, this way you will get the IntelliSense tips about the properties of the elements in that list:
You could probably use the .Modified and .Created properties of the file to achieve that by sorting the list based on that and then picking the top most records. To be extra sure, you could first loop the list and remove the elements that you don’t want, or alternatively loop over it and add the elements you need to a new list.
But, as per your suggestion if I check the .modified property of all the folders that it will not be a good solution as there are more than 10k folders in there. This is why I am searching on how to just get the last 5 created files by some method.
Can we sort the SFTP directory by the date created/modified and get the top 5 folders’ name?
This still forces you to load up all files into the list variable. A solution here would be to group the folders on the server a bit, i.e. having them in separate folders by year and maybe by month.
Another way would be to dynamically generate the path to the folders and fetch one folder at a time, then check if any files were there (or if the folder did exist, it might throw an exception you would catch), and when you grabbed a file, add it to the list until the list has 5 elements.
Linq think i will try but as you said it will required to load the folder in list first.
Creating dynamic names was an option I tried but the folders are not created daily, so in this case we can not simply consider last 5 dates and create dynamic folder names for them that might be the case last 5 days the folders were not created so then we will need to extract the previous ones.
Grouping the folder on the server is not possible as of now as it is up to business but thanks for highlighting this.
I will now surely try the Linq method to see the execution time.