How to enter a string into a path of a file?

I am trying to add “Now.ToString(“yyyy-MM”)” on place of a folder’name “2022”, so that the current year is always indicated in the path. I was able to do that with the help of a colleague, however I am not sure how to do it without having to use the {0}, …? (see picture)

image

Hi @maria.mitova,

Place it inside the double quotes like below.

"C:/Arivu/Pdf/Name"+Now.ToString("MM/dd/yyyy")+"Exchange.xlsx"

Regards,
Arivu

Unforutnately it does not work. I get an errorr message:

image

Hi @maria.mitova ,

Here’s a small workflow which creates a folder/file path using the date format.
This might help you.

TimeFormat.xaml (4.3 KB)

Your syntax is incorrect. Literal text goes inside quotes while expressions (ie now.tostring) stay outside the quotes:

“V:\xxxxxxxxx. Payroll\Payroll Run Documentation\Exchange Rates" + Now.ToString(“yyyy”) + “\” + Now.ToString(“yyyy-MM”) + " Exchange Rates Payroll.xlsx”

Thank you for your answer, but it still does not work. This is the original link:

V:\XX\XXXXX\05. Payroll\Payroll Run Documentation\Exchange Rates\2022\Exchange Rates Payroll.xlsx

This is what I did after your explanation and I got an erorr message:

“V:\XX\XXXXX\05. Payroll\Payroll Run Documentation\Exchange Rates\2022\ " +Now.ToString(“yyyy-MM”)+” Exchange Rates Payroll.xlsx"

What I need to do is to replace 2022 with Now.ToString(“yyyy”) and add Now.ToString(“yyyy-MM”) in front of the last file name.

V:\XX\XXXXXX\05. Payroll\Payroll Run Documentation\Exchange Rates\ 2022\ 2022-01 Exchange Rates Payroll.xlsx

Thanks!

Hi @Indrajit_Banerjee , unfortunately I cannot open it with Studio X.

If that is your goal, this is your code:

“V:\XX\XXXXXX\05. Payroll\Payroll Run Documentation\Exchange Rates\” + Now.ToString(“yyyy”) + “\” + Now.ToString(“yyyy-MM”) + " Exchange Rates Payroll.xlsx"

image

By the way, don’t copy/paste right from these posts. The double quotes won’t be correct. Paste into Notepad, fix all the double quotes to the regular ones, and then copy/paste into UiPath.