Read range latest downloaded file to another file in a different folder

hi RPA experts, Need some help here…
Process steps as below -

  1. Read range from latest downloaded file (dynamic file name in source folder)
    image
  2. Read data from sheet (dynamic sheet)
    image
  3. Copy and paste data from dynamic sheet to file in destination folder (highlighted in yellow)
  4. write data to sheet
    image

What are the steps involved here?

The logic for this program should go like this.

  1. I recommend exploring the possibility to store the file with your chosen name rather than the direct download. (This saves you - and the bot - the time and effort to identify the latest file)
  2. If this is possible, see if you can clean up the folder before downloading the file. That way you only have to deal with the one file, no need to find the latest file.
  3. If 1 or 2 is not possible, then you will need to find the latest file by comparing all the files in the given directory.
    Use File.
    Assign: String() files = Directory.GetFiles("DirectoryName")
    Assign: String latestFilename = ""
    Assign: DateTime latestTimestamp = File.GetLastWriteTime(files(0))
    The above line will assume the very first file in the file list is the latest (for comparison later)
    For each filename in files
    →→ Assign: currentTimestamp = File.GetLastWriteTime(filename)
    →→ If currentTimestamp > latestTimestamp
    →→→→ latestTimestamp = currentTimestamp
    →→→→ latestFilename = filename
    At the end of this loop, the latestFilename value should be the filename which was last downloaded. (This logic is not tested, so might need some tweaks)
  4. To get the sheet name, you can use Get Workbook Sheets activity.
    Assuming the file will only have one worksheet, you can use the first sheet from the list.
    Or if you can confirm that the sheet has the same name as the filename, you can simply use the filename without extension as the Sheet name. (from what I observe in your screenshots, that seems to be the case)
  5. Steps 3 and 4 in your problem statement are straight forward and you already have the right structure up - Excel Application Scope to open “1. Daily Open CRs bFO pullout.xlsx” and use ‘Write Range’ to update the sheet with your copied data.