Copying Excel File (with the previous date) in Folders, To a Destination Folder

Hi all,

I have a file with different folders (a folder for each month of the year, so folders filtered by month), and every folder contains different Excel Files, 1 file for every day of the month.

So I want to create a robot that can copy the Excel File with “Yesterday’s” date, and check all the folders because it may be in one of them not necessary in the folder of this month.
And then copy it to a destination folder.
Any idea how can I do this?

Many thanks for your help!

Much Appreciated.
Best regards.

1 Like

Hi @Ninio,

Welcome to the Uipath Community! :smiley:

  1. First you have to get the excel file name. To do that you have to use Directory.GetFiles(“C:\Users\ExcelsPath to find”) if you want to process multiple files and save it in a String Array variable (String). Also you can use the “Select File” activity if you wish a user to select a specific file he likes.
  2. Then you have to get the directory of the places you wish to look for using the same command Directory.GetFiles(“C:\Users\Folders”) for multiple and store it in another variable of the same type Array String or you can also use the “Select Folder” Activity to look in a specific folder the user selects.
  3. Use a loop and a If. Using the “For Each” activity loop through the array of strings you got. If the name matches any file then do something or don’t do something.

I hope, I explained it well enough but if you have any questions let me know.

Good Luck and happy automation!

1 Like

Hi @rmunro,

Thank you very much for your help and I’m so happy to be part of UiPath Community!

I have used the Directory.GetDirectories(“C:\Users\Folders”) and store it as List String.

And the next step is confusing me since it is a sharedfolder mapped in my File Explorer, and it is updated everyday with an excel file in one of the folders, with yesterday’s date.

So I need to know the exact next steps in order to get that Excel file with yesterday’s date (All excel files name starts with the date, for example: “2020.01.26 Data”). So I need to create a bot to use everyday and copy “yesterday’s date” excel file to a destination folder.

Thank you so much for your help it means a lot! Have a good day!

Hi @Ninio,

I hope you’re doing well as well.

See the below solution:
Main.xaml (5.7 KB)

Thank you so much @rmunro !! However, can you teach me how to get the excel file with name starting with yesterday’s date “yyyy.MM.dd” and copy it to a destination folder? (Noting that this particular Excel file is located in one of the 11 files in a folder, and I need to check all the files in order to get this specific excel file) How can I tell to bot to go through all the folders and subfolders and get this file?

Sorry I’m bothering you, I’m still new to UiPath… Thank you so much for your help.



Once you do the Directory.GetFiles to get the list and files and used the for each use substring to get the first 11 charters since like you mentioned it will always start with this: yyyy.MM.dd the result will be having only the date in one variable if that variable matches yesterday’s date which we know already how to get. Then use copy file activity to copy the file to where you like the file to be copy to.

Thank you very much again @rmunro ! It means a lot really.

Would it be possible to show me the exact codes and steps for the whole process? I would really appreciate it.

Have a good day!

Yes, check this out:
Main.xaml (7.9 KB)

Thank you @rmunro! Much Appreciated!

1 Like

If the BOT couldn’t find the file when it’s run (Yesterday’s Excel file wasn’t uploaded), is there a way to put it in a missing folder? And when it is run the next day we need it to check if the missing folder was uploaded, and if it’s the case to remove it from missing file. Would this be possible?

Main.xaml (10.7 KB)

You can store the files that you didn’t found in a excel or csv file. Then check them next day, as the example attached.

1 Like

It’s working perfectly @rmunro ! Thanks for your assistance!

Is there a way to tell the BOT once it couldn’t find yesterdays file and put it in an Excel sheet, to look again to it the next day (which will be in this case to look at TodaysDate-2 and YesterdaysDate), and then If he can find it to copy it to destination folder along with Yesterdays file?

Thank you a lot. Sorry I am really bothering you. Much appreciated!



It will be the same process as the first. Just read the directory but the directory of yesterday’s files. You will end up having 2 for eachs. You can copy the first part. If it’s too hard, I can probably help you out with another example. Let me know if you were able to do it or not.

Hi Rene,

Thank you for your reply! I tried but I’m still struggling a bit it is not working or I missunderstood… can you send an example if this doesn’t bother you?

1- Create one Excel File Then Add 3 columns with Name File Date , Run 1, Run 2
2- When you run the bot the first time, if you found the file: Add “The Date” in File Date Column, and “Found” in Run 1 Column
3- If you have not found the file then update Run 1 Column As “Not found”
4- When it runs the second time (next day), it should check whether the file is “found” in the first run, if not it should copy the file else update it Not Found"
5- When you are running next day after checking yesterday’s file then check the rows whose values of run 1 and run 2 both as Not found

These are the steps that I am supposed to do @rmunro but I am not able to do it if you can please help me. Thank you!

@rmunro Can you please help me with this if you have time? Many thanks for your support!

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