Find latest downloaded excel file, having random name, and open it

Hello Everyone,

I searched around a bit on the forum for this topic, and found some similar posts, but not exactly what I need, so I took the liberty to start this new thread.

It’s probably very simple, but I can’t found out how to do it.

I am working in salesforce and there I have made UIpath create a report and have it extracted as an excel file, and download the file from salesforce to the standard windows download folder on my computer.

So far so good.

This file will always have a new “random” name generated by salesforce.

Unfortunatey it’s not anything that can be searched for , it’s really quite random, so all “info” I can give UIpath robot is that it starts with the word “report” and it is “the latest file in the downloads folder”.

Example of names of previous report files:
report1602052689965
report1601645385521
report1601643324050

I’m unsure how I can direct UIpath to find the file and have UIpath open it.

Can you help?

Hi there @alhaste,
I am not very experienced on UiPath yet, but if I were you I would do the RPA Citizen Developer course, found in the UiPath Academy page.

I remember a course, might be the Project Notebook course, where you are tought on how to use the ScratchPad.

On this specific case, I would look into these things:

  • Make your bot put the files you have used previously, into a new folder, so that it is only the new report files that are inside the original folder.
  • Now that you only have the new report files in one folder, you can use “For Each File In Folder” and then “Write Cell”, where you can save the names of the files, and use them later.

I believe that if you do the 30 minutes course, which is found under RPA Citizen Developer Foundation, you will figure out how to do this task.

Hope this helped :slight_smile:

Hello,

Thank you for your suggestion. I will try that and update the thread accordingly.

does this help:

?

1 Like

Hello,

I did try to go with the first suggestion, using the “for each file” with the embedded excel workbook, but having a hard time renaming them.

I wll try your suggestion once I get home from work today.

Normally I’m pretty skilled with excel, but and I’m trying to learn how to use it within UIpath which apparently is a bit of a challenge.

Again, thank you for your suggestion, I’ll tst it and get back to you.

1 Like

@studioX, your suggestion worked like a charm.

Glad to learn that the simple if’s still work.

I could not make the =today() work in the project notebook since it gives a REFERENCE error.

It’s not a super big deal since I will instead just remove the file of the original report so old reports will not be an issue.

I will go on now with the next steps and hopefully I can finish it.

@robot.thor also thank you for your suggestion, you showed me not only that I need to do more (all) of the tutorials and learning videos, but also a nice function of the project notebook where I can do a lot of things.

Glat it helped. Can you poat please the reference error? It should have worked…

Maybe I misunderstood. I put the formula into the “scratchpad” part of the "project_Notebook for the project.

Was that wrong?

Here is a screenshot of the error (translated from danish it says “invalid cell reference”

Unavngivet

One final thing, since I used your method, I never got to rename the file, so I’m unsure how to open the file. the name of the file is still in the format "report.xls

I did move it to the correct folder so there is only one file there. Can we do a good old dos command like ren in that folder called through the project notebook by any chance or is there some other sneaky way we can go about renaming the file?

Or can we just open it even though we do not have the exact name, knowing that there is only that one file in the folder?

  1. having excel in danish you need to use the translated formula, i’m not sure, =idag()
  2. the flow doesn’t move the file after detects the today’s file, is using current file based on the date, if you need to move to or rename just use “move file”
    image
    this is to rename in the same folder
    or inside the for each file in folder as in the example flow:
    image

But the flow will know to open the current file if the date is the today date

1 Like

Hi Studiox,

You’re an absolute star.

At the start I was really confused as how to make it work, so I’m very thankful that it’s possible to use normal excel comands like IF.

I did, a few moments ago, find another post where I saw exactly what you’re proposing, and it works perfectly.

I move and rename at the same time now, it’s brilliant.

This is what I ended up with

The =idag() does work (of course I had to use the danish formula and then format it into a date format).

glad is working. i posted few replies earlier the link to the post you said you found. is basically the same scenario!
in the scratchpad, on Date sheet you have some exaples of date formulas that may be used in automating (poiting to them from studiox for example). but having excel in danish you need to do your version in danish.
happy automating

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.