Extract date from file name, subtract one business day, and rename with that date

Hello - we have files saved out in a folder that have the current date (format = YYYYMMDD) saved at the end of the file name, however, the files are related to the prior business day. I am hoping to rename the files using the existing filename date T-1 work/business days. I see that in the notebook it has an option to get the modified date (which would be the same as the current date) and then do a ‘date plus number of working days’, I am just not sure how to use this to rename a file. Any ideas?

I don’t fully follow. Do you want to use/automate the Excel file to make the calculation or do you want to do the calculation with something like an Invoke Code activity directly within UiPath?

So you are looking for something like this?

Current name is FileName_YYYYMMDD.xlsx

You want to rename to FileName_YYYYMMDD-1 xlsx?

Hey @audra.swope ,

I’m assuming you are trying to rename the file from the given date to the previous day. This can be achieved by the following steps:

  1. After you have identified the Date by which the files have initially been named, you can make use of the .AddDays() method to subtract a day from the current Date.
    So, if the date identified is 2024/08/06, we can subtract a day by using the above method as follows:- Cdate(“2024/08/06”).AddDays(-1). This will give us the date 2024/08/05
    image

  2. Then you can make use of the Rename Activity to rename the file to the required Date we found above.

Hi @audra.swope

Try this:

CDATE(YourDate).AddDays(-1).ToString(YYYYMMDD)

For Rename: Use Rename File Activity


image


Hope it helps!!
Happy Automation :uipath:

Hi @audra.swope i assuming you are trying to get that logic - if yes then try this method…
this is your folder structure…
image
image
and in this you want to minus 1 day


output data

Cheers Happy Automation… :grinning:

Thank you all for your help with this. I ended up using this flow for my solution:

In cell B5 of the notebook scrathpad I used various cells (from date tab) and formulas to get the output that i was looking for.

Thank you!

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