Use and read downloaded excel file document with varying file name

Hey All,

I have a use case where I download files into download folder. These files get downloaded with names like “Intra_Day_Pattern_1690279960498” and “Intra_Day_Pattern_1690279701317”

My entire steps are, read the latest one downloaded, do some actions on this excel (consider only read for hypothetical example) once done, delete it and perform this action again after like 2 hours (this can be done by scheduling which is fine)

in the downloaded file “Intra_Day_Pattern_” is common and what changes is the number in the file name which increases every time I download.

I am not sure how to read this file. Is it possible to read it like the file name which stats with “Intra_Day_Pattern” and later delete it so that when I download again there will be only one file with that name. Or any other method.

Could anyone Please suggest

You just need to give an asterisk after the common word Intra_Day_Pattern i.e
Intra_Day_Pattern_*

Regards,

Hi @girishankar09

Try like this

Give asterisk(*)

“Intra_Day_Pattern_*”

If you are downloading this using a browser in the settings of chrome etc you can set it to ask you where you want to download the file and what you want to save it to then you can set it to a static name every time

Unfortunately the dashboard I download gets downloaded directly and does not ask any other details

Could you help me on how I can read a file which starts with “Intra_Day_Pattern_”.

In this case you will need to use the above suggestions using the wildcard asterix to determine the pathway

Hi @girishankar09

Use the below expression to get the files in creation time by descending order.

- Assign -> AllFiles = Directory.Getfiles(folderPath,"*.xlsx").OrderByDescending(Function(d) NewFileInfo(d).CreationTime).Tolist(0)
- Assign -> NewFile = System.IO.Path.GetFileNamewithoutextesion(AllFiles(0))

The NewFile variable has the new file.

Hope it helps!!

1 Like

Any idea how I can write a workflow to read a file which starts with “Intra_Day_Pattern_”. and later delete it?

Yes, If your file startes with Intra_Day_Pattern_ then you can read any file that starts with Intra_Day_Pattern_ by using an asterisk Intra_Day_Pattern_* then use a “delete file activity”

Regards

1 Like

Thanks, I tried the below

Assign
Save to - strPath
Value to Save - “C:\Users\Giri\Downloads”

Assign Save to - intradayfile
Value to Save - Directory.GetFiles(“C:\Users\Giri\Downloads”, “Intra_Day_Pattern_*.xlsx”).FirstOrDefault()

Later I used excel process scope and gave input as variable for use excel however, it does not recognize the file and sheets

1 Like

This actually worked. Thanks all for your suggestions.

If you have found the solution kindly mark as solution and close the thread

Regards

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