How to choose folder and file from date as string?

I have string input = 31/12/2020

I want to write file in folder 2020 and write in file report 12.2020 as below.


Please guide me about it.

Hi @fairymemay

input = “31/12/2020”
strYear = DateTime.ParseExact(strText,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy”)
strDate = DateTime.ParseExact(strText,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM.yyyy”)

You can use create folder activity to create the folder

pass this in the activity “Your Base file path” + strYear

and then use write range activity and “Your Base file path” + strYear + “/Report_” + strDate + “.xlsx”

1 Like

Hi @fairymemay

For this scenario, do the below steps:

  1. Split the date with “/” and assign the arrayofstring to variable.
  2. Check whether the folder was exists.
  3. If yes, then just write the excel or else, create the folder with year and write the excel.

Attached screen shot for your reference.

In WriteRange activity, give path like this:
your2020FolderPath+"\"+splitingString(2)+"\Report "+splitingString(1)+"."+splitingString(2)+".xlsx"

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation


@vignesh.ks Can show your code?


Please find the below image @fairymemay


Note: Variable type should be in arrayofString for this variable.


1 Like

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